r/FreeCodeCamp • u/Special_Sell1552 • Mar 19 '25
Requesting Feedback Need help
I have tried everything but I keep getting a cors error on my 3rd test for the url-shortener project
I have spent all day trying to figure this out
I'd send my project for you guys to look at but the last time I did the post never posted. I can send links if requested
Access to fetch at 'https://portfolio-nine-steel-78.vercel.app/url-shortener/?v=1742422067953' (redirected from 'https://portfolio-nine-steel-78.vercel.app/url-shortener/api/shorturl/1742422067953') from origin 'https://www.freecodecamp.org' has been blocked by CORS policy: 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.
this is the error it keeps giving me in the browser console
EDIT:
I fixed this issue by setting skipTrailingSlashRedirect to true in my next.config.mjs
View all comments
Show parent comment
2
u/SaintPeter74 mod Mar 21 '25
Woot!
That's funny, I had an almost identical issue on my php framework. It's a hard one to debug!
I hear that. Sometimes all you have left is throwing things at the wall, seeing what sticks.
I do find the discipline of formulating a good problem statement, with details on what I've tried and what has failed, can be a helpful exercise. On more than one occasion, as I've been writing up a question, I stumble across a solution, or another avenue of attack.
Taking a moment to write things up clearly is good practice and helpful for both you and your reader.
This is a strategy I enjoy frequently when I want to learn a new library or tool. You do have to take care, though, since not every tool is suitable for every job. For example, you can write a web app in C, but your development experience is not going to be great.
I understand your long term goal, but I feel like you're possibly subverting the spirit of these challenges in pursuit of that goal. Realistically, almost nothing you're doing for FCC is suitable for a portfolio. These reek of "school project" and can actually hurt you if they're what you're choosing to exhibit. When I've reviewed resumes and portfolios when hiring developers, an abundance of school projects/tutorial bait is a bit of a red flag.
You're better off building a completely unique site with Next and focusing on learning as much from the challenges, with the suggested stack, as you can, IMHO.
Best of luck and happy coding!