Hello, I’ve been trying to implement a web service in which I would only have to ‘call’ a REST API workflow by using a GET method.
I’ve done this before using postman and the swagger UI to get a successful result, but when I call it in my web-service (which incorporates a browser, I guess), I tend to get the CORS error saying that
[Request] from origin ‘http://localhost:8080’ 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.
This is the screenshot of the headers minus the authentication on postman.
Am I correct in assuming you are trying to deploy a KNIME workflow as a RESTful web service on a KNIME Server? This isn’t clear from your description.
Can be a bit more specific what exactly you want to achive? Are you trying to call the workflow from inside a web page hosted on a different server?
Yes that is exactly what I am trying to do, deploy a KNIME workflow as a RESTful web service based on an AWS-based KNIME server.
So I have my workflow in the knime server(AWS). My client will call the REST API (GET), then it will run the model with his credentials, and he will get the recommendation.
Then you will need to add an Access-Control-Allow-Originheader the the response from the KNIME Server. This can be achieved by changing the TomEE configuration. The changes should be made in /conf/web.xml. Alternatively you can also run the KNIME Server behind a frontend server and add the header there. For more details on CORS see https://www.w3.org/wiki/CORS_Enabled.
I’ve done my settings as such, and now am getting a “connection refused” message.
Could you help me out where did I set this wrong? The headers I am using from my client side are
Authorization
Access-Control-Allow-Headers
Access-Control-Allow-Origin
Furthermore, if I tweak with the CORS settings, then there is a connection problem that persists within the server. Even when I try to access the workflow from my desktop knime program, the error message comes out saying that the server does not support session cookies.
It would be nice if you could give further assistance on CORS setting.