File Upload Issues

Tell us what’s happening:
I am kinda stuck in the last project of the API and Microservices curriculum, which is supposed to receive a file upload, “parsing” it using multer, and return a JSON response with the filename. the type and the size in bytes. Now, my tests are identical to the website set as example by freeCodeCamp, and the response is also identical. I provide a home route with an html file where there is a form, the input field has the name that is required by FCC, when the file is uploaded it gets a correct routing and a response is sent back with the correct information. However, FCC tests keep failing, basically, all of them and I don’t know why. It is quite tricky to debug since I have no idea what the problem is because the test doesn’t really return anyhting readable or useful for debugging.

I understand that my project is on localhost but it has worked fine so far for the other projects so I don’t think that is the problem. I use morgan as logging middleware and I can see that there is a POST request to the api for uploading the file and the status code is 200. So, I am really out of ideas, could anybody help me please?

Your project link(s)
This is the GitHub link for the project: GitHub - BeGeos/file-metadata-microservice-FCC: FCC project for API and MIcroservices, file uploads

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36

Challenge: File Metadata Microservice

Link to the challenge:

Hi,

I cannot really test your code like it is in github so I just compared your code with mine. It looks good, almost identical to mine. I did enable cors and I don’t see that in your code. Could that do the trick?

Also I don’t see environment variables being handled (require(‘dotenv’).config() but when I commented it out, I still passed so maybe that is not required anymore. My money is on cors
Greets,
Karin

1 Like

Hi Karin,

Thank you very much. It was in fact a CORS problem. You really saved my day, it was such a pain in the bum.

Thank you again,
Marco

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.