#API Request from Frontend to Server in a MERN Project on Local Server in Development

2 messages · Page 1 of 1 (latest)

signal flame
#

Hi guys, I'm trying create a MERN project, I implemented the server side and tested it with postman, it was working perfectly. Then, I tried to make a post request from the frontend and I got 401 error at first, I tried it again and I got 500 error(proxy error: could not proxy request...) the subsequent times. And I already included "proxy" pointing to the port the server is running on the frontend package.json. I'm sorry for the long message, hopefully anyone understands. The MERN project is still in development and both the client-side and server are in the same folder.

nocturne night
#

It sounds like you are encountering issues making a POST request from the frontend of your MERN project to the server. There are a few potential causes for this issue:

The 401 error may indicate that you are not properly authenticating the request on the server side. Make sure that you are handling authentication correctly and that the required credentials are being passed with the request.

The 500 error (proxy error: could not proxy request...) may be caused by a problem with the proxy configuration in your frontend package.json file. Make sure that the "proxy" field is correctly pointing to the port that your server is running on. You may also want to check the server logs to see if there are any issues or error messages that may be related to the proxy configuration.

It is also possible that there may be issues with the server itself, such as a problem with the server-side code or a connectivity issue. In this case, you may want to check the server logs to see if there are any error messages or issues that may be related to the request.

To troubleshoot this issue further, it may be helpful to try the following:

Test the server side of your application using a tool like Postman to ensure that it is working correctly.

Check the server logs for any error messages or issues that may be related to the request.

Check the frontend package.json file to ensure that the "proxy" field is correctly pointing to the port that your server is running on.

Check the client-side code to make sure that the request is being properly formed and that all required credentials are being passed with the request.

Consider adding additional logging or debugging statements to your code to help identify the root cause of the issue.