Axios Error Api local


In my file a have this code

const data = () => {
headers: {
‘Access-Control-Allow-Origin’: ‘*’,
.then(res => {
.catch(function (error) {
The code not working for my local api and I don’t know how to fix it.

This is the console display
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:3000/api/events. (Reason: CORS request did not succeed)

Please i need help

The Access-Control-Allow-Origin header must be sent by the server (i.e. your local API), not the client. I suggest reading the Cross-Origin Resource Sharing article on MDN.

But in my server i have same

app.use((req, res, next) => {

res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');


I just install cors in my server all working :slight_smile: