I’m new to this thing. Basically I have an imgupload
function that makes a request to my backend. The images are uploaded to idrive e2. The backend is running on port 3000 when I run it locally. So while running locally, I set the imguploader URL to localhost:3000/api/uploads.
I’m using Hostinger VPS and when I place my code on it, I’m not sure what to set the URL to. My domain is app.heartstribute.com.
If I replace the URL to app.heartstribute.com, it gives a CORS error. My CORS configuration looks like this:
const allowedOrigins = ['https://app.heartstribute.com', 'https://www.app.heartstribute.com'];
app.use(cors({
origin: (origin, callback) => {
if (allowedOrigins.includes(origin) || !origin) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
},
}));
This is the error I get:
Access to XMLHttpRequest at ‘https://app.heartstribute.com/api/upload/NzhS3dK60AholSIQWMBGfdUfgJW2/undefined’ from origin ‘https://www.app.heartstribute.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
1