500 Error returned from proxy to Heroku API

Hi everyone, I’m currently facing the same issue here.
When I try making a post request to an API endpoint I get a 500 server error, but If I use the API locally on my PC, it works perfectly. Please what could be the issue?

This is a screenshot of my netlify.toml config

Hi @Ayomi

Welcome to the forums

You have a wildcard in the from of the redirect, but you are not using a :splat.

Does it work if you change the redirect to

[[redirects]]
  from = "/v1/*"
  to = "https://gamp-server-staging.herokuapp.com/v1/:splat"
  status = 200
  force = true
  headers = {X-From = "Netlify"}
1 Like

Yeah, I tried doing this.
It’s still gives me the same error

Can you share the URL to a live site to look at?

Yeah, sure.
This is the link:- https://heuristic-liskov-2971b8.netlify.app

I’m trying to login to the application using an API endpoint

If you remove the proxy and use the herokuapp.com URL directly in the code deployed to Netlify, does everything work as intended?

Yeah, locally, it works.
But if I deployed it to netlify and test it, it gives this “CORS” error.

I suspect the CORS issue may still have an impact when used via the proxy method. Suggest settings up CORS headers. See here and here for CORS information, and custom headers in Netlify’s documentation.

1 Like

Thank you! @coelmay
Apparently, there was a CORS rule on the API itself. I have reported it.

1 Like