CORS Control

I get the error "XMLHttpRequest cannot load http://www.testserver.com/json_api.php. Method JSON is not allowed by Access-Control-Allow-Methods." when trying to debug my angularjs project doing a JSON request in webstorms.
The webserver(http://www.testserver.com) with the json_api.php is local and running apache with CORS e.g. headers "access-control-allow-origin    *".

Debugging it with google chrome bulit in debugger it runs fine and the json object is recevied by my client from my server, but not in webstorms where I get the above error.
I am using the built-in webserver in webstorms for my page and when debugging my pages in webstorms it opens up http://localhost:63342/ in chrome.
Have followed the tutorial on http://blog.jetbrains.com/webstorm/2013/06/cors-control-in-jetbrains-chrome-extension/ with wildcard option "

http://*/*
" but still get the error.

Why am I getting ths error when running my app via webstorms, but not via google chrome debuger.
What can I do to solve this?
3 comments

Not sure I follow you... Do you mean that you only get this error when using WebStorm built-in web server, but the same code works fine when using a different web server? If it's so, try using this web server when debugging in WebStorm - what's the reason for using the built-in one?

0

Yes, I get this error only when using the built-in server.
For example when setting up a webstorm project with webserver locally installed it works. Also, just running in google chrome whith google bulit-in debugger it works.

The reason for using the built-in webserver is because the need of just a local simple webserver instead of using, in my case, an separate installed apache web server for this purpose.
So, what can I do in order to making it work with the webstorm built-in web server?

0

CORS pattern looks OK... But your issue is not 'access-control-allow-origin' one, it's 'access-control-allow-methods' - your server returns "Method Not Allowed" whenever your request is sent. Do you have "access-control-allow-methods" header set?

0

Please sign in to leave a comment.