Cross-Origin Request Blocked error while Requesting WebAPI services - ajax

I am working on a OJET framework project on NetBeans. And I am making a call to .Net WebAPI service through Ajax. The request is reaching the server fine and it is getting processed fine, anyhow while receiving the data I can the below error in browser console.
"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource"
I know I am working on cross platforms but not sure how to resolve this issue.
Can anyone help me on this?
Thanks in advance.

Related

ASP.NET WEB API: If CORS is disabled, why I'm allowed to post to the web api from localhost?

Scenario:
CORS is disabled. API is hosted in Azure. Why I'm allowed to post to the web api from my machine, that, that I suppose is localhost domain? Can someone let me know if I have a complete misunderstanding of what CORS does?
Thank you!
While CORS is configured on the server, it is up to the client to enforce it.
Most web browsers do enforce it, and fall back to the same origin policy if it is not enabled on the server.
If you make a request with an HTTP client like Postman, or code running in some other application, CORS is not a factor.

Api Platform & JWT token : I can authenticate but all newt=xt request are 401

I have a client that authenticates to API platform, token is generated and send back to client. Client embed the token in the requests header, but still have a 401 error return from the server : JWT not found. It is in the header thougth (verified with FIrefox)
Have you already had this issue ? (further posts without response).
Is there a possibility Apache or firewall blocks the token ?
How can I find the issue source?
NB: the excat same config was working well on dev server in local. Just clone the git to server and and made acomposer made a composer install. I tried to reinstall lexik, regenrate the .pem.... nothing work
Thank you for your help

Postman 503 Service Unavailable

I tried using postman to test my springboot project. When I sent the request, postman made a 503 error, but when I sent the request in the browser, it successfully got a response.
How to solve this problem?
I had the same issue I resolved it like this :
Postman settings
go to the top right of your postman window Settings > proxy > use the system proxy
for my case I added another proxy so I had to desable it when making a local api call. good luck !
503 Service Unavailable clearly states the server is overloaded, you may be running out of memory. Try again or try to restart the server. The post method will say bad request only. So you should try restarting the server if it is yours, or retry after sometime if it is a 3rd party service.
And also can you check and make sure your postman proxy is turned off. Even that causes problems like these sometimes. Check that in proxy tab.

Response for preflight has invalid HTTP status code 404

This is the responce i am getting when trying to upload a file from my client(PHP),My server is on WebApi which is hosted in one server.In my webapi i have allowed all CORS related things still i am getting this error.
Have you checked this tutorial?
Maybe when you say
In my webapi i have allowed all CORS related things
you didn't do that correctly, or maybe you enabled too many options at the same time.
It's hard to give you more details without access to your actual configuration.
There are also many posts on the same subject here on SO, have you checked them?

Ajax https request issue

When I am calling a REST service through AJAX, its working fine. I am calling it with the URL staring with HTTP e.g.: http://www.myserver.com/customers. Its works really great.
But when I am calling a same URL but with HTTPs e.g.: https://www.myserver.com/customers,
I am not getting any response from server.
Its not working for GET or POST both.
Its not working in Mac firefox, actually I am developing an application for iPhone using phonegap framework.
Its also not working in iPhone simulator's mobile safari.
Can anyone here know what problem is this? And how to solve this?
The requesting domain must match the requested domain down to the protocol, according to the Same Origin Policy
It could probably be because of same origin policy. read
http://en.wikipedia.org/wiki/Same_origin_policy

Resources