-
Notifications
You must be signed in to change notification settings - Fork 374
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
Unnecessary url escaping breaks request paths #2710
Comments
Removing the redirect fixed this issue for me during dev, however, not having this will 100% break my site in production. Perhaps I need to adjust my own server to handle the forwarding that netlify-dev does? [[redirects]]
from = '/*'
to = '/index.html'
status = 200 Edit: I looked into this a bit more. It seems that my server is just getting requested exactly what is shown in my screenshot above. There's not much I can do about this on my end that isn't super janky. Removing the slashes from the redirects sections doesn't do anything either. |
Just to add that I have seen the double slash with my Middleman server. I did multiple installs of netlify-cli to see at which version this started happening and it was on this release. With version
and on version
which causes it to error and not find the page. |
Hello. Just an update. This is still happening with 6.1.0. If I'm not mistaken, this seems to be more of an issue with escaping characters in the URL to be "safe" rather than an extra slash being prepended to the request. I think I should have named this issue "Unnecessary url escaping breaks request paths". Perhaps a flag could disable this feature for the time being? It's quite a nuisance to use For the time being, I'll have to write a flag to run our dev server in "Netlify Dev Mode" to handle the escaped proxied request paths. Edit: if (args['--netlify'] === true) {
req.url = decodeURIComponent(req.url)
req.url = req.url.replace(/^\/\//g, '/')
} |
Hi all 👋 And sorry for the delayed response on this. Can someone post a reproduction scenario/public repo with this issue? I tried with a sample middleman project, but couldn't reproduce |
@erezrokah Hello 👋 ... I don't have a public project I can share atm however I can reproduce this easily in vanilla node with server.js const http = require('http')
const server = http.createServer(function (req, res) {
console.log('>>>', req.url)
})
server.listen(3000, function () {
console.log('listening on port 3000')
}) netlify.toml
Start project
Finally... Go to browser and paste Edit: Edit2: Also, while doing this test, I ran into another weird issue where "uncommon" file extensions would get a Expected behavior would either redirect completely to |
I ran into a similar issue, it actually breaks if the
Running
The encoding mismatch between the proxy config and the request will cause the shouldProxy of the Most likely due to this change (the issue is not reproducible with v3.37.21), hope it helps! |
I have long had the issue with a single project using Astro where I would see the error
Reproducing the error in a basic Astro build has proved rather elusive. However, I have found some further clues. In the [build]
command = "yarn dev"
publish = "dist"
## other bits and bobs
[[redirects]]
from = "/*"
to = "/404"
status = 404 With these settings, if there is a The strange thing is for the project this has always occurred on, the 404 page is never served when the 500 error is produced. However with the barebones test project I have worked on today, the 404 page is served and the 500 error is not produced (as demonstrated below.) Screen-Recording.mov |
Yeah it's pretty clear that If you're able to, you can fix this issue temporarily by undoing the double encoding like this before the request gets passed into your server. I don't know how Astro works, perhaps a middleware or a wrapper? // https://github.com/netlify/cli/issues/2710
req.url = decodeURIComponent(req.url)
req.url = req.url.replace(/^\/\//g, '/') This fixes the issue for slashes only. If you encounter any other characters that get double escaped your paths will break again. I don't have a comprehensive list of characters that |
@coelmay Your issue with the 404 however is working as expected. You're redirecting from The error in this thread about double escaping slashes only happens when you're using a third party server and the redirects at the same time. I believe the effect you're seeing is because the 404 page redirect may not get proxied. Or if it is then I'm even more confused. What a mess. |
The error I am having (as I referenced, and as I mentioned I was not able to fully replicate in the demonstration of which I also mentioned and of which I added a short clip of) is of receiving in error whereby Astro is asked to load the path
which of course does not exist. This is the same as mentioned here. While the framework/method used is possibly (likely) different, the outcome is the same. This rule only redirects paths that do not exist to the 404 page.
If |
I only suspect this is related as I am seeing the same behaviour as @knoxjeffrey with the If this is indeed a separate/unrelated, happy to open a new issue. |
Edit: Retracting previous statement as untrue. |
Describe the bug
I wanted to test out netlify functions using netlify-cli. It seems there's an extra
/
character getting added then escaped.This project works fine when deployed on netlify and when running without netlify-dev. I'm sure it's a simple fix I need to make in my config but I can't seem to find any information in docs or any threads online.
Configuration
CLI Output
The text was updated successfully, but these errors were encountered: