Hello
I’m encountering an error while attempting to consume a REST API developed in webMethods. I’m using JavaScript to make the API call and pass parameters to it. Could someone please help me troubleshoot this issue?
Access to fetch at 'http://localhost:5555/restv2/calculator' from origin 'http://localhost:50683' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.
In a development environment, you can use it to configure the IS to correctly handle the CORS method (the so called preflight request) and the related headers.
In production, you could delegate the management of CORS to a middleware. The API Gateway has a CORS policy that’s pretty straightforward to configure.
CORS is a security protection, you need to white list domains, possibly HTTP methods (even HTTP headers) that can be used to invoke your API from the Javascript code in the web browser. Your organization may want to implement separation of concerns here and ask operating engineers (or SecOps) to deal with this whitelisting.
Access to fetch at ‘http://localhost:5555/restv2/calculator’ from origin ‘http://localhost:55093’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: 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
In your first post the caller script is available at 127.0.0.1 with the port 50683 but in the configuration you’ve mentioned the port 55093. Important to mention the right port in the above parameter.
Restart your Integration Server after the update.
If there is a error, give us the error details you get in your browser console.
By curiosity, what is the server that serve the frontend part ? (Tomcat, HTTP Server, etc.)