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.

Conflicting rewrites #2 - Incorrect paths in Preview Mode (1.18.0-alpha.16)

See original GitHub issue

New 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.
  • 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

Screenshots/Code/Logs

[{
	source: '/:path*',
	destination: '/content/:path*',
}]

Versions

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:closed
  • Created 3 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
patricktyndallcommented, Oct 22, 2020

That’s what I thought too, but from my testing it seemed that Next.js server skips rewrites only for non-dynamic pages and public files

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.

Read more comments on GitHub >

github_iconTop 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 >

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