Hi,
I have a strange situation of where I try to test redirects locally using ntl dev they don’t work.
I was definitely attached to localhost:8888 when testing it.
When I deploy them they do work.
The part that is failing is the simple 404 fall through.
Very small repository if you want to take a look?
Regards, Andy
HI @andystevenson
There is a known issue (or six) with redirects with Netlify CLI. The one most relevant in this case is likely
opened 07:00AM - 17 Jun 21 UTC
closed 03:50PM - 02 Mar 22 UTC
type: bug
area: command: dev
area: redirects
**Describe the bug**
redirects like below redirect to a relative path, not th… e full URL
**To Reproduce**
Setup a redirect and run `netlify dev`. execute `curl -v http://localhost:8888/FROM_PATH_HERE`
**Configuration**
```
[[redirects]]
from = "/download/*"
to = "https://github.com/tetratelabs/archive-envoy/releases/download/:splat"
force = true
status = 302
```
**Expected behavior**
I'd expect `curl -v http://localhost:8888/download/v1.12` to result in a Location: https://github.com/tetratelabs/archive-envoy/releases/download/v1.12
**CLI Output**
**Additional context**
maybe #2327
Thanks @coelmay .
I was just surprised it didn’t work with the simplest of 404 fall-throughs… exactly from the example in Phil Hawksworths Community video.
Regards, Andy
Hi @coelmay I saw recently they updated the netlify-cli but still no joy with the redirects working locally.
Is there any acknowledgement of this being an issue?
Is there a workaround I could try?
Very frustrating to have to deploy the site before seeing any redirects working.
Which redirect(s) specifically are you having issues with?
I cloned the repository you shared. After running ntl dev
and browsing to a non-existent path I see
Cannot GET /asd/index.htm
This is described in the following issue on the Netlify CLI repository
opened 07:07PM - 15 Sep 20 UTC
closed 02:22PM - 30 Aug 22 UTC
type: bug
area: frameworks
area: command: dev
**Describe the bug**
The following rule is not applied for non static servers… (when a framework is detected):
```
/* /index.html 200
```
**To Reproduce**
Steps to reproduce the behaviour:
1. Run `git clone https://github.com/11ty/eleventy-base-blog.git test-project`
2. `cd test-project`
3. `npm install`
4. `rm 404.md` (this is important so 11ty won't redirect to a custom error page)
5. `echo "/* /index.html 200" > _redirects`
6. Run `BROWSER=none netlify dev`
7. Visit `http://localhost:8888/test`
See that you get an error from 11ty `Cannot GET /test/index.htm`
**Configuration**
```bash
System:
OS: macOS 10.15.6
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 1.67 GB / 32.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.9.0 - /usr/local/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 6.14.8 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
npmGlobalPackages:
netlify-cli: 2.63.2
```
**Expected behavior**
The `index.html` file content should be returned.
**Additional context**
Related to the discussion here https://github.com/netlify/cli/issues/794#issuecomment-610619793 and to https://github.com/netlify/cli/pull/810
The following does work:
```
/* /index.html 200!
```
```
/* /index.html 302
```
I believe the test [here](https://github.com/netlify/cli/blob/d76df759c9517191f946bc3d43a14bc3d50b0a7b/tests/cra.test.js#L58) passes since `create-react-app` re-routes unknown routes to the index page. Meaning the redirect is handled in `create-react-app`.
The solution is to request the resource from the framework server - if it returns 404 redirect, otherwise don't redirect.
As an public repository, you are welcome to add your voice to it.
Many thanks @coelmay . I will add my voice to it.