Redirect rules from netlify.toml when using netlify dev

Just started trying out netlify dev this afternoon, and it seems as though none of my redirects are being processed (I’m proxying calls to /api to an external server), just getting 404 responses when I hit them while using the dev server. All of my redirect rules are defined in netlify.toml in my root directory, rather than in a _redirect file, is this support in the dev cli tool?

Cheers
Joe

Hi @joe-pritchard,

Yes, redirects defined in your netlify.toml file should be supported. If this is not what you are seeing, could you file an issue in the project’s repository with details about your issue?

I’m using redirects successfully with Netlify Dev by defining them in my netlify.toml file as I would normally. I’m proxing calls in a similar way to how you are describing @joe-pritchard.

The netlify.toml lives in the root of my project and I included some redirect definitions which looks like this:

[[redirects]]
  from = "/images/small/*"
  to = "https://example-nlm-picture.netlify.com/images/:splat/?nf_resize=fit&w=500"
  status = 200

I would like to perhaps have some different redirect definitions for dev to what I have when deployed, only because I’m using them here to access deployed assets directly from the Netlify image transform API as part of Netlify Large Media so the root URL I might define could be different.

Do you know if deploy contexts reach through to dev @Dennis ?

1 Like

Hey @Dennis , sorry I’m only just now replying! Actually the issue was that I was trying to put my redirect inside a deploy context, which it turns out is not supported, so it was my mistake really

Cheers
Joe

Edit: @philhawksworth if you’re trying to conditionally do redirects different for different contexts like I was, I don’t think it will work …

Ah yea, redirects aren’t context-based so that won’t work. I can add your voice to the feature request though.

Should I be placing redirects in netlify.toml instead of in _redirects, then?

[pause]

Aha. It seems I should have read this: Issue with Redirects and Jekyll - #4 by swyx

1 Like

thanks for linking that in here @jbrains! post again if you still need help.