Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Rewrites Breaks in Production mode #25097

Closed
simmbiote opened this issue May 13, 2021 · 3 comments
Closed

Custom Rewrites Breaks in Production mode #25097

simmbiote opened this issue May 13, 2021 · 3 comments
Labels
bug Issue was opened via the bug report template. please add a complete reproduction The issue lacks information for further investigation

Comments

@simmbiote
Copy link

simmbiote commented May 13, 2021

What version of Next.js are you using?

10.1.3

What version of Node.js are you using?

12.13.1

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

next start

Describe the Bug

With custom rewrites in next.config.js, the application breaks when hitting /api/ routes in Production mode.

Expected Behavior

The application should not break on /api routes.
A break that occurs in production mode should have occurred in development mode.

To Reproduce

  1. Add a custom rewrite to next.config.js:
const rewrites = async () => [
  {
    source: "/:path*",
    has: [
      {
        type: "host",
        value: "(?<host>.*)",
      },
    ],
    destination: "/:path*?host=:host",
  },
];

(rewrites is then used in config...)

  1. During development mode, running is fine.
  2. Build the application.
  3. Start the application and hit any route except home.

An error as follows is experienced:

TypeError: Cannot read property '__nextLocale' of undefined
at Router.execute (C:....\node_modules\next\dist\next-server\server\router.js:19:712)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Server.run (C:....\node_modules\next\dist\next-server\server\next-server.js:69:1042)
at async Server.handleRequest (C:....\node_modules\next\dist\next-server\server\next-server.js:34:504)

@simmbiote simmbiote added the bug Issue was opened via the bug report template. label May 13, 2021
@danielsimao
Copy link

Hey @simmbiote, I opened an issue with a similar behaviour but when on purpose open the page with 2 slashes ("//"), to see if it would go to error page.

#23772

Checkout the codesandboxes

@ijjk ijjk added the please add a complete reproduction The issue lacks information for further investigation label Jul 24, 2021
@ijjk
Copy link
Member

ijjk commented Sep 19, 2021

Hi, I'm gonna close this as this appears to be working correctly in the latest version of Next.js v11.1.2 please update and give it a try!

@ijjk ijjk closed this as completed Sep 19, 2021
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. please add a complete reproduction The issue lacks information for further investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants