Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access-Control-Allow-Origin header contains the invalid value

I have created html page with form submit. On submit i am calling ajax post request. But throws a error

Failed to load http://radius.a3techlabs.com/app/custom/verifyAccessOTP: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains the invalid value ''. Origin 'null' is therefore not allowed access.

$.ajax({
      url: 'http://radius.a3techlabs.com/app/custom/verifyAccessOTP',
      dataType: 'json',
      type:'post',
      headers: {
          "charset":"UTF-8",
          "accept": "application/json",
          "Access-Control-Allow-Origin":"*",
          "Access-Control-Allow-Credentials":"true",
        },
      data:value,
      success: function(data) {
        console.log(data);   
        alert(data.message);
      }.bind(this),
      error: function(xhr, status, err) {}.bind(this)
    });
like image 881
San Daniel Avatar asked Sep 15 '25 10:09

San Daniel


1 Answers

module.exports.cors = {
  allRoutes: false,
  origin: '*',
  credentials: true,
  methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
  headers: 'content-type'
};

changed

allRoutes:true

module.exports.cors = {
  allRoutes: true,
  origin: '*',
  credentials: true,
  methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
  headers: 'content-type'
};

it works,

like image 82
San Daniel Avatar answered Sep 18 '25 09:09

San Daniel