CORS Not working in firefox

I have an ajax script:

  type: "POST",
  url: ``,
  data: 'Action=SystemLogin',
  crossDomain: true,
  dataType: 'application/x-www-form-urlencoded'

This works fine in chrome and edge but Firefox says:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (Reason: CORS header 'Access-Control-Allow-Origin' missing).

I tried adding:

 headers: {
                   'Access-Control-Allow-Origin': '*'

But no good, any ideas?
Thanks in advance.

This is a security issue regarding the fact that the AJAX request is being made to a different domain adress , I advise trying to fix this instead. What will happen otherwise is browsers will try to prevent you from grabbing this data

This is a response header returned by the server, not a request header sent by the client.
If you don’t have access to change the server response, then you may not be able to request it across domains with ajax.

1 Like

I’m not to bothered about security as it’s running on the local network.

So why does it work in chrome?

Chrome can be set up to disable web security, such as for when running in a local environment.

With CORS, basically you need the place you are requesting information from, to have that Access-Control-Allow-Origin setting in their header. If you have control over that, then get it done.

If you do not have control over that, you will need to ask them to add your server to their Access-Control-Allow-Origin

If they do not want to do that for you, then you’re stuffed, and other solutions need to occur instead such as using PHP to fetch the information instead, which is outside the purview of us here in this JavaScript channel. The PHP channel should be able to help with that instead.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.