matthewmueller / matthewmueller/next-redirect

Query parameters get escaped on client but not server

Open
#2 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
52
Forks
7
PR merge metrics
No merged PRs in 30d

Description

I'm trying to redirect to a login page with a query parameter:

nextRedirect(context, `/login?from=${context.asPath}`);

This works fine when it's run on the server, but when it gets run on the client, the ? in the path gets encoded as %3F leading to a 404 not found (because the path ends up being /login%3Ffrom= instead of /login?from=.

I'm gonna throw together a PR.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue provides no file or test names. Start by reproducing the client-side redirect with the shown nextRedirect call and compare it with server-side behavior; done means the query delimiter remains ? and /login?from=... resolves instead of producing a 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js
Domain
web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.