next.js icon indicating copy to clipboard operation
next.js copied to clipboard

9.1.5 path-to-regexp error with static routes

Open ERRORthenBSOD opened this issue 6 years ago • 4 comments

Bug report

Describe the bug

Ok i'll try again.

After i upgraded next to 9.1.5 from 9.1.4 i can`t run it in production. I got express and my command is NODE_ENV=production node server.js

And it gives me:

.../node_modules/next/node_modules/path-to-regexp/dist/index.js:113 throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type); ^

TypeError: Unexpected MODIFIER at 72, expected END at mustConsume (.../node_modules/next/node_modules/path-to-regexp/dist/index.js:113:15) at parse (.../node_modules/next/node_modules/path-to-regexp/dist/index.js:172:9) at stringToRegexp (.../node_modules/next/node_modules/path-to-regexp/dist/index.js:329:27) at pathToRegexp (.../node_modules/next/node_modules/path-to-regexp/dist/index.js:403:12) at Object.match (.../node_modules/next/node_modules/path-to-regexp/dist/index.js:248:14) at Object.route (.../node_modules/next/dist/next-server/server/lib/path-match.js:6:42) at .../node_modules/next/dist/next-server/server/next-server.js:386:37 at Array.forEach () at Server.generatePublicRoutes (.../node_modules/next/dist/next-server/server/next-server.js:381:21) at Server.generateRoutes (.../node_modules/next/dist/next-server/server/next-server.js:146:20)

Also: now after my yarn.lock or package.lock changed i get this error no matter what 9 version of next i install. On 8 version there is no such error

The bug happening when you try to create routes to your static content in production environment. There was no such error before you upgraded dep path-to-regexp to 6 version. It was 3 in 9.1.4

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. npx create-next-app --example custom-server-express custom-server-express-app or yarn create next-app --example custom-server-express custom-server-express-app
  2. Create public folder
  3. Create svg file with content
 <svg width="23" height="10" viewBox="0 0 23 10" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.5" d="M3.9834 10H2.71191V1.57129L0.162109 2.50781V1.35938L3.78516 -0.000976562H3.9834V10ZM13.0273 6.65723H14.4082V7.68945H13.0273V10H11.7559V7.68945H7.22363V6.94434L11.6807 0.046875H13.0273V6.65723ZM8.65918 6.65723H11.7559V1.77637L11.6055 2.0498L8.65918 6.65723ZM19.3027 4.66113H22.0781V5.85742H19.3027V9.00195H18.0312V5.85742H15.2559V4.66113H18.0312V1.75586H19.3027V4.66113Z" fill="black"/>
</svg>

  1. Put that svg in public folder
  2. Run NODE_ENV=production node server.js

Expected behavior

Route created for static svg -> server started

System information

  • OS: MacOS 10.15
  • Version of Next.js: 9.1.5

ERRORthenBSOD avatar Dec 11 '19 12:12 ERRORthenBSOD

I cannot reproduce with the instructions given. The SVG loads fine: image

See setup: image

Timer avatar Dec 11 '19 13:12 Timer

Oh i got it. Try to change name test.svg to 14+.svg The problem here in naming with special symbols i guess

ERRORthenBSOD avatar Dec 11 '19 14:12 ERRORthenBSOD

How to reopen it?

ERRORthenBSOD avatar Dec 11 '19 14:12 ERRORthenBSOD

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.

balazsorban44 avatar Jan 30 '22 21:01 balazsorban44