You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an error when executing a get request in a ReactJs app does generate the following
"XMLHttpRequest cannot load http://localhost:3002/api/users. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3005' is therefore not allowed access. The response had HTTP status code 404."
I have an error when executing a get request in a ReactJs app does generate the following
"XMLHttpRequest cannot load http://localhost:3002/api/users. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3005' is therefore not allowed access. The response had HTTP status code 404."
My Code.
const ROOT_URL = 'http://localhost:3002';
const AUTH_TOKEN = 'eyJ0eXAiOiJKV1QiLCJhb..................';
axios.defaults.baseURL = ROOT_URL;
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=utf-8';
axios.get('/api/users').then(function(response) {
console.log(response.data);
console.log(response.status);
console.log(response.statusText);
console.log(response.headers);
console.log(response.config);
});
The text was updated successfully, but these errors were encountered: