Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.
This repository was archived by the owner on May 10, 2021. It is now read-only.

netlify.toml redirects aren't obeyed #80

Closed
@ChrisBAshton

Description

@ChrisBAshton

Situation: I was trying to allow requests to /random to be proxied to /api/random.

I edited my netlify.toml to add this:

[[redirects]]
  from = "/random" 
  status = 200 # turns the redirect into a proxy
  to = "/api/random"

But ended up getting this output under out_publish/_redirects (i.e. the custom proxy wasn't registered):

# Next-on-Netlify Redirects
/  /.netlify/functions/next_index  200
/api/random  /.netlify/functions/next_api_random  200
/*  /:splat  200

I tried creating a _redirects file instead:

/random /api/random 200

This was being picked up in the output 🎉

/random /api/random 200!

# Next-on-Netlify Redirects
/  /.netlify/functions/next_index  200
/api/random  /.netlify/functions/next_api_random  200
/*  /:splat  200

However, requests to /random continued to 404. I guessed this was because Netlify only allow one hop. So I changed the contents or _redirects to:

/random /.netlify/functions/next_api_random 200!

...and now it's doing what I want 😁

I don't think there's much we can do about the one-hop limit, but next-on-netlify claims to look at the netlify.toml for redirects, and that doesn't appear to be working 🤔 is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions