Get 520 error when fetch from netlify proxy

netlify.toml file:
from = “/api/storefront”
status = 200
force = true
headers = { X-From = “Netlify”, X-Shopify-Storefront-Access-Token = “TOKEN_HERE”, accept = “application/json”, Access-Control-Allow-Origin = “*”, Content-Type = ‘application/json’ }

Deploy also said redirect rule processed successfully:

The thing is it’s WORKING on netlify dev, but NOT WORKING when publishing on a branch preview build by gatsby build.

Any help could be appreciated.

Hey @Jolum,

Error! JSON Parse error: Unrecognized token '<'

Perhaps you’re trying to output something that isn’t JSON. Try using a console.log before your response so that you can check out the output :slightly_smiling_face:.

Nope, not about the JSON, because we can’t get the correct data at the first place. As i noted above, this is working on netlify dev. But not when published on netlify server.

because we can’t get the correct data at the first place

this is working on netlify dev

Which is it? :face_with_hand_over_mouth:.

It works on your custom domain but not on your branch. Should something be set at the API-end to allow particular domains, perhaps?

Umm by netlify dev means that it’s working on localhost:8888 using netlify cli so the connection is 200.
But when we deployed on netlify environment. We get that error 520. I am not sure what that error is?

So it’s sure that when on localhost it’s working, then should be no probs at the API-endpoint right?

On the flip side, it works here, no?

No that’s not using proxy, i just tried to use netlify deploy --prod and it results in request directly on the 3rd Party API. (not via proxy) You can see it on network tab.

The 520 is the response from CloudFlare and here’s their debug guide which I’d definitely try and run through.

Thanks a lot, much appreciated :pray:

1 Like

Hello @Pie how is this going? any luck what causing it? Cheers

Hey @Jolum,

Sorry if I wasn’t clear – their debug guide is something which you should take a look at as I believe that this is their response.