Cli: 200 Redirect not working

Created on 7 Sep 2019  ยท  4Comments  ยท  Source: netlify/cli

- Do you want to request a feature or report a bug?

Bug

- What is the current behavior?

Says URL is rewritten, but does not proxy correctly (get 404)

Investigating, req.url is rewritten and passed off to proxy.web, not sure why that isn't enough.

Using a 301 redirect works as expected.

- If the current behavior is a bug, please provide the steps to reproduce.

[[redirects]]
from = "/things/:id/:slug"
to = "/things/:id"
status = 200

- What is the expected behavior?

Arrive at content of "/things/:id"

- Local Environment Information
Paste the results of netlify status --verbose here

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Environment Info โ”‚
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

System:
OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Binaries:
Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
Browsers:
Chrome: 76.0.3809.100
Firefox: 68.0.2

(related to Zendesk ticket #13879)
gz#13879

Most helpful comment

I've ingestigated this and it seems like the URL routing at the netlify dev is working but when gridsome sees /a/b instead of / in it's frontend Javascript, it displays the 404 page. This is a known issue and has no simple solution because the URL routing is handled by gridsome in this case instead of routing to different actual files like on the production server.
We're exploring a few ideas on how to make this work on different frameworks. (e.g. React with react-router)

All 4 comments

Hey @cco3 , thanks for filing a report. I just investigated this and tried to reproduce the issue. I couldn't reproduce this on the latest version. Can you make sure that you're on the latest version of the CLI and take another look at the current behavior example you provided.

Hm, so playing around with this a little more, I couldn't get it working with a static directory. I also seem to need multiple path segments in the source path to reproduce the issue.

gridsome create test
cd test
cat << EOF >> netlify.toml
[[redirects]]
  from = "/a/b"
  to = "/"
  status = 200
EOF
netlify dev

Visit http://localhost:8888/a/b. It claims the URL is rewritten, but 404s.

  • gridsome 0.7.1
  • netlify 12.15.0

I've ingestigated this and it seems like the URL routing at the netlify dev is working but when gridsome sees /a/b instead of / in it's frontend Javascript, it displays the 404 page. This is a known issue and has no simple solution because the URL routing is handled by gridsome in this case instead of routing to different actual files like on the production server.
We're exploring a few ideas on how to make this work on different frameworks. (e.g. React with react-router)

This has been fixed in the latest version. Now we hand off all requests to application server (gridsome in this case) that are not:

  1. Redirects (301, 302)
  2. External URL's
  3. Internal URL's (/.netlify/*)

without rewriting the URL.

Please update to latest version of [email protected] and let us know if the problem still persists.

Was this page helpful?
0 / 5 - 0 ratings