Tell us what’s happening:
Describe your issue in detail here.
When I use curl
or the repl.it web interface on my current project, I see the output I expect from my code:
sean@work:~> curl -d "url=www.freecodecamp.com" -X POST https://boilerplate-project-urlshortener.seandoe.repl.co/api/shorturl
{"original_url":"www.freecodecamp.com","short_url":"placeholder"}
However, when I run the FreeCodeCamp tests, the associated test fails. Specifically, this test:
" You can POST a URL to /api/shorturl
and get a JSON response with original_url
and short_url
properties. Here’s an example: { original_url : 'https://freeCodeCamp.org', short_url : 1}
"
You’ll see in my code that I’ve explicitly enabled CORS with app.use(cors())
However, when I use the developer tools during the FreeCodeCamp test runs, I receive multiple CORS errors:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://boilerplate-project-urlshortener.seandoe.repl.co/api/shorturl. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘*, *’).
I don’t expect my project to pass all tests yet, as I haven’t implemented URL shortening- however, I can’t tell if I’m doing something fundamentally very wrong, or if I’m having testing issues because of some kind of interaction between replit and FCC. I log the URLs that FCC is passing, and I don’t understand their contents, it looks like the project is calling itself, however I checked the request body and this is the literal only url present:
url: 'https://boilerplate-project-urlshortener.seandoe.repl.co/?v=1641749593580'
Furthermore, I’m able to click the link and it DOES resolve.
Thank you in advance for your time- and if you need any additional information I’m happy to provide it.
Your project link(s)
solution: https://replit.com/@seandoe/boilerplate-project-urlshortener
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0
Challenge: URL Shortener Microservice
Link to the challenge: