Error Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers

0 votes

I have a simple PHP script that I am attempting a cross-domain CORS request:

<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
...

Yet I still get the error:

Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers

Anything I'm missing?

Jul 6, 2020 in Java-Script by kartik
• 37,520 points
479 views

1 answer to this question.

0 votes

Hello @kartik,

Access-Control-Allow-Headers does not allow * as accepted value.

Instead of the asterisk, you should send the accepted headers (first X-Requested-With as the error says).

Hope it helps!!

Thank You!!

answered Jul 6, 2020 by Niroj
• 82,760 points

Related Questions In Java-Script

0 votes
1 answer

Error:No Access-Control-Allow-Origin header is present on the requested resource node.js

Hello @kartik, My guess is that you're serving ...READ MORE

answered Jun 8, 2020 in Java-Script by Niroj
• 82,760 points
1,767 views
0 votes
1 answer

Error:“Access is denied” error on accessing iframe document object

Hello @kartik, Basically, this error occurs when the ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,760 points
1,125 views
0 votes
1 answer

Error:Invariant Violation: _registerComponent(…): Target container is not a DOM element

Hii @kartik, Basically what you done is right, ...READ MORE

answered Jun 8, 2020 in Java-Script by Niroj
• 82,760 points
1,312 views
0 votes
1 answer

Error:“Access is denied” error on accessing iframe document object

Hii @kartik, The problem was that even though the ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,760 points
596 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,760 points
7,772 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,760 points
877 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,760 points
706 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,760 points
8,236 views
0 votes
1 answer

Error:Origin is not allowed by Access-Control-Allow-Origin

Hello @kartik, The easiest way to handle this ...READ MORE

answered Jun 17, 2020 in Java-Script by Niroj
• 82,760 points
474 views