Replies: 6 comments
-
On Mojolicious backend add this under the startup function
I believe it will fix the CORS issue |
Beta Was this translation helpful? Give feedback.
-
Sorry I dont understand where to add this. my test script here.
|
Beta Was this translation helpful? Give feedback.
-
This is not a bug in mojolicious. I wish there was a button to move an Issue to the Discussions page instead but as far as I understand it there is no such function. As it is I will close this Issue but I encourage the discussion to continue by moving to the Discussion page. |
Beta Was this translation helpful? Give feedback.
-
Oh, my apologies, I see it now! |
Beta Was this translation helpful? Give feedback.
-
Absolutely it's not a bug. My bad, posted in a wrong area. hook after_dispatch => sub { Seems to be working. Need to check further. |
Beta Was this translation helpful? Give feedback.
-
It should work otherwise try with
|
Beta Was this translation helpful? Give feedback.
-
Steps to reproduce the behavior
I keep getting "Access to XMLHttpRequest at 'http://12.34.56.78:8075/' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." for hello world like web services. This is happening when I call these services through browser or AJAX.
Sample PHP Code:
Expected behavior
This Mojolicious web service http://112.34.56.78:8075/ returns {text: "Hello World"}
I tried to add the below header as well.
$c->res->headers->access_control_allow_origin('*');
Actual behavior
I am getting the above error in the browser debug console.
Beta Was this translation helpful? Give feedback.
All reactions