api is not working on live site
hi guys maybe someone can enlighten me about the api on how do i get a live api for my deployment, because currently i deployed my project in vercel not knowing that i have not yet turn my local host into live?the image is not there but the text is there
8 Replies
Check dev console for more details
i think the problem is my fetch is a local host. can you pls help me how do i make the local host in public?
ngrok
will allow you to tunnel a port on localhost
out to the public Internet.
It's not hard for an experienced dev to operate, but it sounds like you might be less experienced.
In the long term you need your API server to be running on a machine outside of your LAN.
If you're using Next.js for your API server, it will be running on whatever hostname Vercel gives you. Connect to that host rather than localhost
.
Without knowing more about your architecture, it's difficult to diagnose this & give suggestions.i use render to deploy my api so i can use this url in my front end but then i encounter this issue Access to fetch at 'https://restaurant-recipe-1.onrender.com/gallery' from origin 'http://localhost:3000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:5173' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
in server.js i already have this
To format your code blocks, use three backticks at the start and end of your code block. You can also add the language like
```
thank you
anyone can help? maybe we can call?
You see on the second line where you're setting the CORS origins? Add your Render server there.
ok will try it now
i add all the url i have in the cors and now it work https://restaurant-recipe-project.vercel.app/