@DragonOsman
Web Developer and Programmer (learning MERN stack development and C++)
I'm an aspiring web developer. I was born in Saudi Arabia and have been to the US. I have a developer portfolio that I want to increase traffic on so I can get some potential clients.
Freelance work, remote job internships, or actual remote jobs
Hi, and thanks for this awesome article. I have this MERN app I've deployed to Vercel (my GitHub username is DragonOsman. Please go to my GitHub page and go to the personal-library repo; the deployment link is on the right-hand panel). I setup CORS and a proxy (proxy key in client directory package.json that points to the server URL), and the paths and methods are all correct as far as I can see, but I still get a 405 error when I try to send a POST request to my login route. Source code repository is on my personal-library repository (DragonOsman/personal-library). Any help is appreciated. [I have to describe like this because I can't post links yet.] Thanks. Edit: I removed proxy and only kept CORS, which I'm doing like this: const CLIENT_URL = "<client_url>" ; app.use(cors({ origin : [ ` ${CLIENT_URL} ` , ` ${CLIENT_URL} /` ], methods : [ "GET" , "PUT" , "POST" , "DELETE" ], credentials : true })); but I still have a CORS error in my browser's console that says: Access to fetch at '<backend_login_url>' from origin '<client_url>' has been blocked by CORS policy : Response to preflight request doesn 't pass access control check: No ' Access -Control-Allow-Origin ' header is present on the requested resource. If an opaque response serves your needs, set the request' s mode to 'no-cors' to fetch the resource with CORS disabled. I added res.setHeader("Access-Control-Allow-Origin", [CLIENT_URL, ${CLIENT_URL}/ ]); on all my routes, right at the start of the function code block, and I also added app.options("*", cors()); (tried it both before and after my app.use(cors({...})) call). But that error won't go away. What should I do?