Hello guys. i use vite reactjs and nodejs for an ecommance website with MERN Stack method, all working fine while texting in localhost and after deploying my server to render and my client side to netlify to test my project, i got into series of issues, firstly cross-origin problem
error message: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ‘https://bamstore-store.onrender.com/api/users/getLoginStatus’. (Reason: Credential is not supported if the CORS header ‘Access-Control-Allow-Origin’ is ‘*’).
here is my cors setup:
/ CORS middleware
app.use(
cors({
origin: “https://bamstoreng.netlify.app”, // Explicitly specify the allowed origin
credentials: true, // Important for cookies, authorization headers with HTTPS
methods: [“GET”, “POST”, “PUT”, “DELETE”, “PATCH”, “OPTIONS”],
allowedHeaders: [
“Origin”,
“Content-Type”,
“Accept”,
“Authorization”,
“X-Request-With”,
],
})
);
i have tried different method even worked with chatGPT but still a deadend… i used cookies to store token for my header , getLoginStatus and LoginUser… with this issue a user can not login nor register .
testing my render API works perfectly but connecting with netlify gave me this issue,
problem 2. accessing product details hits 404 page not found which is working fine normally
https://bamstoreng.netlify.app/product/65da7795015087a65daa3250
product id assigned properly and id is being fetch…
please who can help me out and any area of my code you will like to review please ask so i can provide it. Thanks in advance