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

Path rewrite Unhandled Runtime Error #24661

Closed
Kulakoff1988 opened this issue Apr 30, 2021 · 4 comments · Fixed by #24956
Closed

Path rewrite Unhandled Runtime Error #24661

Kulakoff1988 opened this issue Apr 30, 2021 · 4 comments · Fixed by #24956
Labels
bug Issue was opened via the bug report template.

Comments

@Kulakoff1988
Copy link

What version of Next.js are you using?

10.1.3

What version of Node.js are you using?

14.16.0

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

next start

Describe the Bug

When i use the webpack5: true in my next.config.js it failed with error

Unhandled Runtime Error
TypeError: (0 , _resolveRewrites.default) is not a function

const rewritesResult = resolveRewrites(
> 1489 |         addBasePath(addLocale(asPath, this.locale)),
       |        ^
  1490 |         pages,
  1491 |         rewrites,
  1492 |         parsed.query,

Expected Behavior

There is no error have to be. It works fine without webpack5: true flag

To Reproduce

Add to your next.config.js next code:

module.exports = {
  future: {
    webpack5: true,
  },
  async rewrites() {
    return [
      {
        source: "/your_parh/:path",
        destination: "/api/:path", 
      },
    ];
  },
};
@Kulakoff1988 Kulakoff1988 added the bug Issue was opened via the bug report template. label Apr 30, 2021
@hokkun-dayo
Copy link

hokkun-dayo commented May 2, 2021

Same here. Even I'm using next.config.js without future and webpack settings (I have some rewrite rules in that file though).
According to https://nextjs.org/docs/messages/webpack5,

In the next minor version we'll automatically opt-in applications without custom webpack configuration in next.config.js

Seems that I'm affected by that change.

The workaround for me is to add the empty webpack config:

module.exports = {
  // the existing settings...
  webpack: {},
};

@Kulakoff1988
Copy link
Author

@hokkun-dayo update: there is no error, if i work on Ubuntu. I guess this error occurs only to Windows.

I didn't trying your workaround yet on Windows, but it seems ugly imho)))

@ijjk
Copy link
Member

ijjk commented May 11, 2021

Hi, this should be fixed in the latest version of Next.js v10.2.1-canary.5, please update and give it a try!

@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 28, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants