Skip to content

Fix fallback false #858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 9, 2025
Merged

Conversation

conico974
Copy link
Contributor

Dynamic route with fallback false can wrongly intercept and return 404 for routes that intersect with them.

Fix #677 and opennextjs/opennextjs-cloudflare#611

Copy link

pkg-pr-new bot commented May 7, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/aws@858

commit: ccdb493

...metadata,
})(req, res);
} catch (e: any) {
if (e.constructor.name === "NoFallbackError") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could that cause issue with minification?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to test it. Not sure what we can use if we can't use that, i don't think we can use instanceof

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work in cloudflare in preview

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a concern, there is a keep_classname option in the webpack config.

Copy link

changeset-bot bot commented May 7, 2025

🦋 Changeset detected

Latest commit: ccdb493

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch
app-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@conico974 conico974 requested a review from vicb May 9, 2025 13:20
@conico974 conico974 merged commit f25c249 into opennextjs:main May 9, 2025
3 checks passed
@github-actions github-actions bot mentioned this pull request May 9, 2025
@lauri865
Copy link

App router's export const dynamicParams = false; seems to be broken still :(

@sommeeeer
Copy link
Contributor

App router's export const dynamicParams = false; seems to be broken still :(

what version of OpenNext are you on? when you say broken, what do you mean?

@lauri865
Copy link

Cloudflare@latest (=1.0.4)

Same issue as the referenced issue:
opennextjs/opennextjs-cloudflare#611

@lauri865
Copy link

Sorry, correction, the original issue seems to be fixed. Repro doesn't reproduce it anymore, but we seem to be hitting a new issue it seems (fallback rewrite doesn't get triggered, and we end up with 404 in a different scenario). I will see if I can create a new reproduction soon.

@sommeeeer
Copy link
Contributor

Sorry, correction, the original issue seems to be fixed. Repro doesn't reproduce it anymore, but we seem to be hitting a new issue it seems (fallback rewrite doesn't get triggered, and we end up with 404 in a different scenario). I will see if I can create a new reproduction soon.

@lauri865 Alright. The reproduction you linked here doesn't have any dynamicParams in it. It seems to be missing a commit.

@lauri865
Copy link

Sorry, correction, the original issue seems to be fixed. Repro doesn't reproduce it anymore, but we seem to be hitting a new issue it seems (fallback rewrite doesn't get triggered, and we end up with 404 in a different scenario). I will see if I can create a new reproduction soon.

@lauri865 Alright. The reproduction you linked here doesn't have any dynamicParams in it. It seems to be missing a commit.

I corrected that in the meanwhile as well, was missing a commit indeed. Thanks for pointing out.

@lauri865
Copy link

lauri865 commented May 27, 2025

New reproduction committed: https://github.com/lauri865/opennext-routes-repro

pnpm dev / start work just fine (shows this Github issue when you navigate to any non-existing page, e.g. http://localhost:3000/abc123

If export const dynamicParams = false; is present:
pnpm preview shows 404 also for static path /test that should exist, and the fallback rewrite in next.config doesn't work for any non-existing path.

So, it seems like it's impossible to opt out from dynamicParams, and if you try to do that, it breaks static params as well.

@conico974
Copy link
Contributor Author

@lauri865 You need an incrementalCache in your open-next.config.ts

@lauri865
Copy link

lauri865 commented May 27, 2025

We havestaticAssetsIncrementalCache in our production config, but facing the same issue. Do we need something else? Our site us fully static.

Updated that repro with staticAssetsIncrementalCache and it has the same issue.

@conico974
Copy link
Contributor Author

@lauri865 Create an issue with a link to the repro, then

@lauri865
Copy link

lauri865 commented May 27, 2025

@conico974, I did, it's referenced as fixed by this PR. Which it seems to be not. Should I open another issue?

@conico974
Copy link
Contributor Author

@lauri865 Yeah, that's not the same issue:

Sorry, correction, the original issue seems to be fixed. Repro doesn't reproduce it anymore

@lauri865
Copy link

Opened a new issue here with a reproduction: opennextjs/opennextjs-cloudflare#682

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pages Router catchAll route with fallback:false cause 404 on api route
5 participants