I'm working on REST services at the moment and running into CORS problems.
To explained it, I took the example in vibe.d-0.8.4/examples/rest-js
This restserver runs using http://127.0.0.1:8080/
I build a second (client) server running http://127.0.0.1:9000/ to consume the rest services.
For consuming I took the test.js from the rest server.
I got the message:
Access to XMLHttpRequest at 'http://127.0.0.1:8080/compute_sum?a=1&b=2' from origin 'http://127.0.0.1:9000' 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.
In a second step:
I gave the rest server additional code
setting restsettings.allowedOrigins = ["*"];
On the client side I added
xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); before xhr.send();
Same CORS issue
Using the rest server on any browser (the direct way = same url, same port) works fine.
How to solve?
Thanks & Regards, Ozan