Comments (8)
@tino-junge ok so! i know what's going on and where it's going wrong in the source, but i'm not entirely sure why at this moment or how exactly to move forward.
this line is true only for non-default locale root routes (aka /pl
or /fr
etc). when shouldAddLocalePrefix
is true, it passes a condition (this same condition therefore fails for non-root routes like /pl/static
) and sets up a 307 (aka the infinite redirects we're seeing for /pl
).
therefore, my understanding is that your bug only exists for /pl
(and for pages where you have a Link
to /pl
because the Link tries to prefetch unless you set prefetch to false) in preview mode (aka when we SSR your page with this 307 logic instead of serving the pre-rendered html).
like i said earlier, it's unclear to me right now why this is needed on vercel / why/how this works on vercel. for the record, i was able to strip out the contentful bits of the repo you shared while keeping the reproduction of the bug (see commit). if you can confirm this is in fact only an issue for you on root non-default locale routes in preview mode, that would be helpful in the meantime! (aka, can you successfully visit a page /pl/some/other/route in preview mode?)
will circle back once i have another update!
from next-on-netlify.
@lindsaylevine hi lindsay, thanks for looking into that. I realised that our preview setup might be quite custom and therefore hard to reproduce. I'll try to get a sample setup working and share it with you soon.
from next-on-netlify.
@tino-junge just saw this! can confirm i also see the infinite redirects; thank you so much for taking the time to put this together!! will dig into shortly and keep you updated :)
from next-on-netlify.
for transparency on the issue (even though tino already knows what's up :)):
this issue vercel/next.js#21943 was opened on vercel/next.js but i didn't want to link to it directly given that this is a netlify-specific project :/ i've confirmed with tino that patching next.js resolves the issue he reported here (#164). if you'd like the same workaround until next.js maintainers respond or until we can figure out a better, longer term solution, see it here: lindsaylevine/next-netlify-contentful@456f265 and let me know if you have any issues!
from next-on-netlify.
fixed per vercel/next.js#22445 :) shoutout to jj from vercel/next.js for fixing it!
from next-on-netlify.
@tino-junge hey tino! thanks so much for opening this detailed issue. unfortunately, after a lot of tinkering, i haven't been able to repro what you're experiencing. what you're reporting is likely super specific to the page type of whatever you're trying to preview, your exact logic, setup, etc. that said, i have to ask you to build/share a barebones deployable repo that reproduces your issue exactly :/. i know this may seem impossible given that you're using contentful, but at this moment, i don't believe this is connected to contentful; i believe this could be reproduced with the exact logic you're using in your api/preview and directly visiting the "broken" url in preview mode. i encourage you to try to repro it without contentful.
apologies i can't be more helpful without an exact repro :( let me know and feel free to ask whatever in the meantime!
from next-on-netlify.
Hey @lindsaylevine, I finally got a sample setup ready for review:
I've created a fresh Next + Netlify project (based on your netlify starter kit, thanks cassidoo!). When I've added my custom Contentful preview setup and NextJS i18n-routing I was able to reproduce the issue.
When visiting the the production site, the i18n routing works fine (by clicking on the locales).
However when using our content preview url, it only works for the default locale. When using the non-default locale pl
it spins in infinite redirects. You can observe a few redirects in the network tab before it times out. Content preview for the non-default locale does work on localhost though.
You can have a closer look at the implementation of the preview functionality in the sample repo.
Let me know if that's enough context. I'd be curious to understand if it could also be my setup which is causing the issue.
Links
Production: https://nostalgic-ride-32aba8.netlify.app/
Preview URL: https://nostalgic-ride-32aba8.netlify.app/api/preview?secret=local-test-secret&redirectUrl=%2F
Repo: https://github.com/tino-junge/next-netlify-contentful
from next-on-netlify.
Hey @lindsaylevine, thanks for your update on that. Yes I can confirm: the redirect bug within preview mode only occurs actually on the index page for /pl
, but works fine for other routes like pl/features
from next-on-netlify.
Related Issues (20)
- Add tests for root level index pages of all page types for i18n
- Use splats in SSG redirects instead of adding a redirect for every exact prerendered path HOT 5
- Investigate tradeoffs between redirects and copying files [to correct paths] HOT 1
- Netlify post processing/bundling causes some rendering to be blocked HOT 4
- "blocking" on getStaticPaths' fallback throwing ambiguous error HOT 1
- Cannot find module 'critters' HOT 2
- Missing `pages-manifest.json` HOT 1
- Failure when the publish directory is `public`. HOT 1
- Cannot find module 'jimp' HOT 12
- Header config causes CLI to throw "invalid rule: cannot contain anything after *" HOT 7
- _redirects sorted wrong when using catch all route and dynamic routes HOT 4
- Add clarification for deployment with submodules HOT 4
- Cannot find module critters HOT 15
- Forward options params to "nextOnNetlify" function from node command-line args HOT 1
- Allow API routes to optionally run as background function HOT 3
- "The 'path' argument must be of type string. Received undefined" when using next-auth HOT 18
- Missing locale files with next-i18next HOT 10
- Timeout error when using MongoDB in getServerSideProps HOT 4
- *** deprecating next-on-netlify *** (info & feedback) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-on-netlify.