Cross origin null forbidden: Axios tries to make an xhr request in a Node environment, instead of an http request.
See original GitHub issueAxios tries to make an xhr request in a Node environment, instead of an http request.
// It doesn't work
import axios from 'axios';
const { data } = await axios.get( 'http://example.com' );
// It work
import axios from 'axios';
import adapter from 'axios/lib/adapters/http';
const { data } = await axios.get( 'http://example.com', { adapter } );
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Error: Cross origin null forbidden during post request
While performing a post request, I am getting the cross origin null forbidden error. I have an Html page with js file called ......
Read more >axios - npm
Promise based HTTP client for the browser and node.js. Latest version: 1.2.1, last published: 22 days ago. Start using axios in your project ......
Read more >Cross-origin Errors - React
If an error is thrown from a different origin the browser will mask its details and React will not be able to log...
Read more >Adding CORS support to an API proxy | Apigee Edge
CORS (Cross-origin resource sharing) is a standard mechanism that allows JavaScript XMLHttpRequest (XHR) calls executed in a web page to ...
Read more >axios has been blocked by cors policy - You.com
axios has been blocked by cors policy: response to preflight request doesn't pass access control check: no 'access-control-allow-origin' header is present ...
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 FreeTop 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
Top GitHub Comments
It’s a issue due to Jest default environment. https://facebook.github.io/jest/docs/en/configuration.html#testenvironment-string
What creates
XMLHttpRequest
and misleads this function: https://github.com/axios/axios/blob/9a6abd789f91a87d701116c0d86f1cfbc3295d66/lib/defaults.js#L16-L26To fix this I had to add this in my
jest.config.js
file:@bertho-zero where i can find this file?