Type error Failed to fetch

I’m using AWS API gateway. I enabled CORS in AWS, but in appgyver the error message is: Error: TypeError: Failed to fetch. Does the server allow CORS?status: undefined

What is appgyver expecting for a response to get this resolved?

Are you able to test your API via Postman or other method? I’m using AWS API Gateway (+CORS) successfully using both “REST Api Direct Integration” as well as HTTP Request flow function. Which are you using?

To troubleshoot the HTTP Rest flow function I’ve been adding a Javascript flow function so I can pipe the output (response body or error) to the console and to get more info quickly.

Yes I can run it through Postman. I am using REST Api direct integration in the data tab. If CORS sends back a 200 status it does not send the request to lambda. If CORS sends back a 400 status, the lambda goes through but the response sends back 400. What should it be for appgyver to find it?

Can you use the web inspector (Cmd+Opt+I on Mac, Ctrl+Alt+I on Windows) to see the raw response from the server and take a screenshot of it? Alternatively, if you give us your app ID and tell which data resource it is, we can test it on our end.

I have the same problem.
Error: TypeError: Failed to fetch. Does the server allow CORS?status: undefined

Hi, could you answer the same questions Harri asked above? It could help us understand the issue.

I have the exact same problem. I can’t be sure I’ve found my app ID, but I think it’s the one in the URL (167685). I’m testing the FoodCentral API:

Hi! Sorry it took a long time to answer :frowning: Can you check what the error looks like using this method:

If there’s nothing useful there, I’ll have a look next week :slight_smile:

When I press Ctrl + Alt + I after a failing test as per above screenshot, nothing happens. I clicked to activate all kinds of things and then pressed it, but still nothing happens. In a new Chrome tab, all it does is type “í” into the search bar.
Not sure if it helps but aside from the # in my app’s URL, in the build service I found “Build 269910”.

Hi! Sorry my answer is super late, I was away sick for a week :frowning: Perhaps the right combination is ctrl + shift + J (as listed here) to open the JavaScript console. Please try again looking from there.

No idea what this means exactly:


How do I turn on “Access-Control-Allow-Headers in preflight response”?

Hi, I’m not super knowledgeable about the backend side of things, but from the error message it sounds like either you have a typo in the field api_key that you’re trying to provide to the backend, or it’s not the right type of field (sounds like it should be a header), or the backend does not want the api_key in this format, or is not configured to receive it. You’d need to check from your backend in what format it wants the (GET) requests in :disappointed_relieved:

Yes the API documentation is explicit about requiring the ID number, so I’m not sure what to do. There is no way within AppGyver I think to pass the number to the API as a string vs. number, if that is required. Or is there?

The String/number distinction doesn’t actually affect the call itself. You can see which format it comes out by looking at the developer console’s Network tab. If the URL does look correct, check that the server allows CORS as indicated in the message.

Hi Mavi. I have this error…


Could you help me?
Thanks

Hi, I am also facing the same error. Things just never work in this tool

Hi

Same issue here with google Maps API

https://maps.googleapis.com/maps/api/directions/json
give up this error however

https://maps.googleapis.com/maps/api/geocode/json

does not…

both work from postman…

5:1 Access to fetch at ‘https://maps.googleapis.com/maps/api/directions/json?key=GOOGLEAPIKEY4&origin=ttttt&destination=ttttttt’ from origin ‘https://platform.appgyver.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
raven.js:1619 GET https://maps.googleapis.com/maps/api/directions/json?key=GOOGLEAPIKEY&origin=ttttt&destination=ttttttt net::ERR_FAILED 200

I’m fairly sure the request is received by google. Its the reply to appgyver is the problem.

2 Likes

Whenever CORS error or similar appears, check if the same request works if done from Android / iOS. If it works in Android / iOS but not in web / Composer, it’s a CORS problem and has to be fixed from the backend side. If it does not work anywhere, then there is probably something configured wrong.

For google maps API, use the HTTP request and try it on Android / iOS and see if it works. Might be that google has blocked using maps API in web (the CORS problem).