the below attached file is my Login.js (client side)
const createOrUpdateUser = async (authtoken) => {
return await axios.post(
`${process.env.REACT_APP_API}/create-or-update-user`,
{},
{
headers: {
authtoken:authtoken,
},
}
);
};
Here is my env file
REACT_APP_REGISTER_REDIRECT_URL = 'http://localhost:3000/register/complete'
REACT_APP_FORGOT_PASSWORD_REDIRECT ='http://localhost:3000/login'
REACT_APP_API = 'http://localhost:8000/api'
The Output : As shown in the image below, I have a POST request for http://localhost:800/api and then in the login file I have post-fixed it with /create-or-update-user but it throws a Status Code : 404 Error
The Output just in case the image doesn't load : Request URL: http://localhost:3000/'http://localhost:8000/api'/create-or-update-user [1]: https://i.stack.imgur.com/wxije.png
CodePudding user response:
You have superfluous quotes there, remove all the '
from your environment variables:
REACT_APP_REGISTER_REDIRECT_URL=http://localhost:3000/register/complete
REACT_APP_FORGOT_PASSWORD_REDIRECT=http://localhost:3000/login
REACT_APP_API=http://localhost:8000/api
Since 'http://localhost:8000/api'/create-or-update-user
isn't a valid absolute URL (it starts with a quote and not a protocol), it's interpreted as relative URL right now.