skip to Main Content

Netlify deploy with _redirects file not working for http api.

After deploying my react app to netlify I encountered an issue caused by Netlify being on HTTPS protocol and the API that i’m trying to reach on HTTP – Mixed content. So I did some research that I have to proxy the API to be called over HTTPS and for that I have to use _redirects file.

/base/* http://exampleapi.com/:splat 200

And I restructured my endpoints to be like this:

process.env.REACT_APP_NETLIFY + "/base/app/getById?" + urlParams

When I deploy my site, I can even see that redirects file gets processed, but the error message remains.

xhr.js:247 Mixed Content: The page at 'https://rahvatantsuk.netlify.app/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://eampleApi.com/app/getDances?accountId=4002'. This request has been blocked; the content must be served over HTTPS.

What’s weird is that I thoguth I fixed this issue with redirects and it actually worked in production for a while but now I see this error once again. Any ideas?

2

Answers


  1. Chosen as BEST ANSWER

    Soi I misunderstood netlifys docs and restructured the api string to be "/base/app/getById?" + urlParams and now it works :)


  2. Add the _redirects file in your src folder and in the file add these line and try deploy /* /index.html 200. It worked for me.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search