_redirects Netlify Dev works only with 200 status code

Hi, I have a problem with redirects using Netlify Dev.
I’m trying to redirect a local path (e.g /foo) to an external url (e.g https://netlify.com) with Netlify Dev. In my _redirects I’d like to have this simple entry: /foo https://netlify.com. From the doc the default status code should be 301. When I deploy , all works, but on my host using Netlify Dev, the redirects to path other than the local ones are redirected to the home page. The only way I found to have the redirects to external domains working, is to force a 200! status code: /foo https://netlify.com 200!, but it’s not the semantic I’d like. Moreover, only in this last scenario I’ve the following logs from Netlify Dev

◈ Reloading redirect rules from [ '_redirects', 'netlify.toml' ]
      Regenerating: 1 file(s) changed at 2021-11-29 16:51:22
                    _redirects
       Jekyll Feed: Generating feed for posts
                    ...done in 0.058692 seconds.
                    
◈ Proxying to https://netlify.com/
[HPM] Proxy created: /  -> https://netlify.com

A weird things with 200 status code is that in Netlify Dev, the URL after redirect changes and it shouldn’t be (see https://docs.netlify.com/routing/redirects/rewrites-proxies/)

Does anyone experience a similar issue? How did you solve?

Thank you.
Best,
Mattia

Hi @Mattia_Ducci,

I don’t see it happening myself. Could you share a reproduction repo?

Hi! Yes, this is one of my attempts: Mattia / ProvaJekyllNetlifyCLI · GitLab. I installed the Netlify CLI when I wrote the post, few days ago. Now I’m not at my pc at work, so I’m not sure about the exact node version. If you think it could matter I’ll let you know tomorrow
Can you share me the repo that’s ok for you so I can test on my machine please?

Thank you very much,
Mattia

I downloaded your repo and tried to reproduce this. Here are my findings:

  1. Your repo didn’t totally work for me. I tried running netlify dev but the Jekyll server immediately crashes.
  2. Before crashing, it builds your website in the _site folder. So I ran netlify dev in that folder and it has these _rediects:
/bbb /about

/bizz /

/foo https://netlify.com 200!

All of these seem to work fine. When it visit localhost:8888/bbb, I get sent to /about and so on.

First of all thank you for your time trying my website. _redirects to the same website works well for me too. The one that point to an external domain (in my example /foo https://netlify.com) doesn’t work to me unless I write 200!. I don’t know why it crashes the server :thinking: any idea? Do you think I did something wrong?

Thank you again

Hi @Mattia_Ducci,

Looks like you’re correct. I’ve filed an issue for the devs here:

1 Like

Hi! I’m sorry for the delay! Thank you very much!