Getting 'Cross-Origin Request Blocked' on a GET request
See original GitHub issueSummary
I’m making a GET request to 4chan’s API for retrieving threads from a board. This is my code:
const board = this.props.routeParams.tag;
var config = {
headers: {'Access-Control-Allow-Origin': '*'}
};
axios.get('https://a.4cdn.org/' + board + '/threads.json', config)
.then(function (response) {
console.log(response.data);
});
I receive the following warning:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://a.4cdn.org/a/threads.json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
As seen above, I have added the relevant header, but it does not solve the issue. I made the same request from my terminal using cURL and it worked fine.
Context
- axios version: e.g.: v0.16.0
- Environment: e.g.: node v6.9.4, Firefox 51.0.1, Ubuntu 14.04
Issue Analytics
- State:
- Created 6 years ago
- Reactions:111
- Comments:143
Top Results From Across the Web
3 Ways to Fix the CORS Error — and How the Access-Control ...
If the frontend domain does not match the value, the browser raises the red flag and blocks the API request with the CORS...
Read more >If I get a cross-origin-request-blocked error on my front-end ...
The server then decides whether to allow the request or not. If the browser gets permission from the server, then it sends the...
Read more >CORS errors - HTTP - MDN Web Docs - Mozilla
If the CORS configuration isn't setup correctly, the browser console will present an error like "Cross-Origin Request Blocked: The Same ...
Read more >CORS errors and how to solve them - Topcoder
CORS is an abbreviation for Cross-Origin Response Sharing. It is what allows the website on one URL to request data from a different...
Read more >The Cross-Origin Request Blocked Error - Logi Analytics
Cross -origin resource sharing (CORS) is a new standard introduced in HTML 5 that allows web applications to use HTTP headers to specify...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Access-Control-Allow-Origin is a response header, not request header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
axios.get(url, { headers: {‘Access-Control-Allow-Origin’: *} } ) means nothing!
try axios.get(url, { crossdomain: true })
Any news on this? I’m pretty much in the same boat…