REST API gives a CORS status undefined error

HI,

Im getting this error when testing the REST API.

Error: TypeError: Failed to fetch. Does the server allow CORS?status: undefined

Resource settings for Get collection (GET)

Resource URL: https://secure.codeczar.co.uk/ef-member-service/rest/member/loginWithUsernameAndPassword
Relative path: undefined

Can you please help me resolve this error?

Sorted.

The CORS configuration goes into the web.xml file of Apache Tomcat . We need to add the following filter

CorsFilter org.apache.catalina.filters.CorsFilter CorsFilter /*

Hi I’m getting the same error.
TypeError: Failed to fetch. Does the server allow CORS?status: undefined

i’m confused as to whos Apache web.xml file needs to be updated. I’m running this in composer pro, it has not been deployed.

Also it only happens when I use a Path Variable
Regards

Hi James,
It’s okay if your app hasn’t been deployed. We were in this same situation.

  1. You connect via REST API? I assume this. Your REST URL sends a HTTPS request to a physical server.
  2. This request is either picked up by an Apache or NGINX web server that processes this HTTPS request.
  3. Now this Apache or NGINX web server should be configured to allow CORS request.
  4. In our case it was an Apache web server. In its config folder, there is a web.xml file. Just add the above code in that file.
  5. Restart your Apache Server. This will do the trick.
  6. If your web server is an NGINX, that can be configured to all CORS too. Just google on how to allow NGINX for CORS. You’ll get your thr necessary code required that has t be added. Restart your NGINX server.
    7, now try connecting from Appgyver. It should work.
  7. If it does not, try connecting to your server from https://www.test-cors.org/
  8. At times your browser may nit be able to send a CORS request, there are extensions that you can install that allow CORS. just search from Allow CORS in the install extension settings from your browser and white list the URLs. That should do the trick from thr client browser. This step may not be necessary.

Hope this helps. We solved out problem this way.