question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

9.1.5 path-to-regexp error with static routes with special symbols * ( +

See original GitHub issue

Bug report

if you place files in public folder with symbols * ( ) + and run node server.js in production you will get something like

/node_modules/next/node_modules/path-to-regexp/dist/index.js:80
                throw new TypeError("Unbalanced pattern at " + i);
                TypeError: Unexpected MODIFIER at 1, expected END

or

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

Describe the bug

This is bug with path-to-regexp. And it happens only in 9.1.5 after upgrade path-to-regexp from version 3 to 6.

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 any file with any symbol from * or ( or + . For example logo18+.png
  4. Put that file in public folder
  5. 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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
evenfrostcommented, Jul 6, 2020

@markotom you should change usage of * in routes to (.*) or :splat* as per koajs/router v9 changelog.

1reaction
Timercommented, Jan 10, 2020

Fixed in 9.1.8-canary.11 – please give it a try!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'length' of undefined at pathtoRegexp ...
The reason behind that error is using the app.get() method without param, which expect the endpoint url and call back as parameters.
Read more >
Configure Path Monitoring for a Static Route
If you decide that you want specific Layer 3 traffic to take a certain route without participating in IP routing protocols, you can...
Read more >
D6.5 Collaborative Cloud Solution Platform
The development of the platform of INNOVACONCRETE project is one of the activities related to WP6 dealing with the Conservation Approaches ...
Read more >
Configuring IPv4 Static Routes - Gaia Portal
conf command. For more information, see sk92799. 8. In the Comment field, enter the applicable comment text (up to 100 characters) ...
Read more >
path-to-regexp - npm
Express style path to RegExp utility. Latest version: 6.2.1, last published: 8 months ago. Start using path-to-regexp in your project by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found