Rewrites with conflicting paths
See original GitHub issueThis is continued from the discussion in https://github.com/serverless-nextjs/serverless-next.js/issues/646
Reproduction here: https://github.com/patricktyndall/sls-next-bug-reproduction
Describe the bug
When rewrite paths conflict with /public or static routes in /pages, things start breaking.
Actual behavior
/dynamic-1, /login, and /my-test-asset.txt break
Expected behavior
/dynamic-1, /login, and /my-test-asset.txt don’t break
Steps to reproduce
Deploy using serverless
Versions
- OS/Environment: MacOs
- @sls-next/serverless-component version:
@sls-next/serverless-component@1.18.0-alpha.13
- Next.js version:
9.5.5
Additional context
This is important because it prevents existing next.js apps from using this component, as it breaks compatibility.
I added comments in next.config.js on what happens when you change the rewrites.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12
Top Results From Across the Web
How can I fix & solve merge conflicts? - Tower Git Client
From time to time, merge conflicts will happen in any Git project. Here's a detailed guide on how to deal with them.
Read more >Routes having conflict in URL rewriting or configuring route in ...
In my project I am providing REST API for mobile devices. But I am having a problem with configuring route for URLs of...
Read more >Git merge conflicts | Atlassian Git Tutorial
What is a git merge conflict? A merge conflict arises when Git cannot automatically resolve code differences between two commits. Learn more here....
Read more >how fix rewrite rule conflict - Webmasters Stack Exchange
The quick fix is to simply reverse these two directives, so the more specific rule (that matches exactly 2 path segments) is first....
Read more >Resolve conflicts | IntelliJ IDEA Documentation - JetBrains
Under distributed version control systems, such as Git and Mercurial, conflicts arise when a file you have committed locally has changes to the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep, I do note that - just was trying to clarify how it’s implemented right now - it just takes the first matching rewrite and tries to rewrite it (it doesn’t know about no-ops, doesn’t know about existing non-dynamic pages or static/public files).
I did test the repro with the dev server and confirm your findings. Even with or without the no-op rewrite, it looks like next also doesn’t rewrite non-dynamic routes such as
/login
(so/:path*
to/content/:path
is not going to rewrite/login
, as/login
has priority).However, for dynamic routes like
/content/dynamic-1
, the no-op rewrite seems to prevent those from being rewritten (your destination is/content/:path
, so I changed this to something else to test this - either another internal route or external route).I think this has helped cleared things out. So looks like there are two things to fix:
Fixed and released in latest alpha.