Comments (8)
In fact, the URL only gets shadowed/rewritten when the square brackets are URI encoded:
https://example.com/%5B%5B...any%5D%5D.js
. On the other hand, the request forhttps://example.com/[[...any]].js
works totally fine. So that led us to suspect that perhaps the netlify.app logic for checking if a local file exists may not correctly decode URIs.
thank you for pointing out that detail. seems to be something we'd want to fix in the future. i'll make sure to open an internal issue.
would there be a way to publish that file without special characters for now?
from next-on-netlify.
#77 re-addresses this :)
from next-on-netlify.
Hi @Yegair,
Thank you for your kind words and for this detailed issue report! I think you are absolutely right — it's probably related to issue #41.
@lindsaylevine is already in touch with the team that manages the Netlify redirects/rewrites feature, to see if they can dig into the issue. We will keep you and everyone else posted here!
For now, it's best to use the "no-op redirect" you mentioned.
Stay tuned and thanks again for the report & repo to reproduce the issue! 🔥
from next-on-netlify.
@FinnWoelm i'm curious: why wouldn't you add that /_next/* /_next/:splat 200
rule to the redirects file in the build process of next-on-netlify?
it seems to always be a good idea right?
from next-on-netlify.
Hi @mraerino, thanks for checking this out! Really appreciate your help!
All redirects generated by next-on-netlify
are non-force redirects, so they should not shadow existing files. This always works correctly, except in the case where the asset has a square bracket in its filename. Then the URL gets shadowed even though a local file exists!
In fact, the URL only gets shadowed/rewritten when the square brackets are URI encoded: https://example.com/%5B%5B...any%5D%5D.js
. On the other hand, the request for https://example.com/[[...any]].js
works totally fine. So that led us to suspect that perhaps the netlify.app logic for checking if a local file exists may not correctly decode URIs.
Adding to that suspicion is the fact that this issue only occurs when a catch-all redirect is present, such as: /* /myfile.html 200
. Without that redirect, the URL with encoded square brackets yields the correct file. With that redirect, the same URL with encoded square brackets incorrectly gets rewritten to myfile.html
.
Please correct me if I'm wrong, but doesn't the fact, that a redirect with /_next/* /_next/:splat 200
solves this issue, further add to the suggestion that there is an issue with decoding the URI? The redirect should not be necessary thanks to Netlify's shadowing rules (unless, of course, we had some forced redirects in our _redirects
file, but there aren't any).
We wanted to raise this issue (rather than locally fix it with /_next/* /_next/:splat 200), in case there is actually an issue with the shadowing logic. Because if so, it might affect others using SPA with catch-all redirects (.e.g., a React app with /* /index.html 200) and local files with square brackets in their names (admittedly, it's not super common to have these in your file names).
Does that make sense? Am I mistaken in my understanding of how things should work? Happy to chat more at any time, if it would be helpful!
from next-on-netlify.
Hey @mraerino, that's awesome to hear!! 🙌 😊
We can't publish it without special characters (it's created that way by the framework and there are a lot of internal references to those files with square brackets), but I think we will do the /_next/* /_next/:splat 200
thing as you have suggested!
Thank you again for looking into this :)
from next-on-netlify.
Hi @FinnWoelm,
I'm facing this issue when I have something like pages/index.js
& pages/[...rest].js
.
The temporary /_next/* /_next/:splat 200
fix does not get applied in this case as it is not considered root level catch-all route.
The redirects generated are
/:rest/* /.netlify/functions/next_rest 200
from next-on-netlify.
@afzalsayed96 looking into this, thanks for reporting!
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
- [i18n] preview redirects are failing with non-default locales HOT 8
- 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.