Conflicting rewrites #2 - Incorrect paths in Preview Mode (1.18.0-alpha.16)
See original GitHub issueNew issue per maintainer admonishments. This is continued from https://github.com/serverless-nextjs/serverless-next.js/issues/696, same setup as there (@dphang).
Describe the bug
When using top-level rewrite (per past issues – see rewrites / repo below), upon visiting a route in preview mode, the incorrect URL is passed to getStaticProps
(via params
). Issue goes away if rewrites are removed, or if not in preview mode.
Actual behavior
URL slug passed in params
to getStaticProps
is incorrect.
Expected behavior
URL slug passed in params
to getStaticProps
is correct.
Steps to reproduce
- Deploy my example
- Visit this URL:
/api/preview?secret=96ffe7d4-2ad2-4699-b64a-a5f74750962e&slug=/dynamic-1
- Either check logs, or simply look at the page. The
params
key incorrectly has part of the rewrite destination in it.
- Either check logs, or simply look at the page. The
- For added fun, visit the non-rewritten URL for the same page
/api/preview?secret=96ffe7d4-2ad2-4699-b64a-a5f74750962e&slug=/content/dynamic-1
- The app now thinks we’re at
/content/content/dynamic-1
- The app now thinks we’re at
Screenshots/Code/Logs
- Reproduction: https://github.com/patricktyndall/sls-next-bug-reproduction
- The rewrite in question:
[{
source: '/:path*',
destination: '/content/:path*',
}]
Versions
- OS/Environment: Mac
- @sls-next/serverless-component version:
1.18.0-alpha.16
- Next.js version:
9.5.5
Additional context
~If you visit /content/dynamic-1
not in preview mode, you get a 404. This is also a bug, and is actually a regression added in alpha.16
.~
Issue Analytics
- State:
- Created 3 years ago
- Comments:15
Top Results From Across the Web
Rewrites - next.config.js
Rewrites act as a URL proxy and mask the destination path, making it appear the user hasn't changed their location on the site....
Read more >release-notes - Paket
Paket now clones git dependencies as bare repositories and configures clones under paket-files differently. Because of these incompatible changes, it is ...
Read more >SDK and Worker Dependencies - Dataflow - Google Cloud
The Apache Beam SDKs and Dataflow workers depend on common third-party components which then import additional dependencies. Version collisions can result ...
Read more >Vulnerability report for Docker centos:latest - Snyk
Learn more about Docker centos:latest vulnerabilities. Docker image centos has 416 known vulnerabilities found in 416 vulnerable paths.
Read more >What's new in Unity 2022.1.0 Alpha 7 - Unity
ShaderGraph: UI shaders are not rendered in Game View from 2021.2.0b2 (1352225). UI Builder: Changes in UI Builder are lost when editing a...
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
PR for (1): https://github.com/serverless-nextjs/serverless-next.js/pull/719
Good catch on this, that’s definitely not intuitive. I would have thought to skip rewrites for anything with a non-dynamic segment. (I wonder if this holds for non-catch-all dynamic segments / rewrites). I guess this is the utility of the “no-op”; that’s not explained well in the next docs.