cors error on custim nginx server
Unanswered
gref9730 posted this in #help-forum
gref9730OP
hello I have all fetches created as this where im using "http:"
but im hosting the app on custom linux server where I have set up nginx which listens on port 80 and propagate it to the next js app which is running on "localhost:3000"
...nextConfig. it all worked before I created with certbot for the nginx a ssl certificate ... now im getting on all fetches CORS error and whe I tried to change in all fetches functions to
"https" ... and tried to rebuild the app im getting errors while building that the fetches cant reach target and that it doesnt exist... probably bcs the next js app is running on http
and the nginx is running on https ... but idk what to do now to make it work..
anyone can help?
asnyc function randomFetch(val: string){
const response = await fetch('http://${process.env.URL}/api/something',
{
cache: "no-store",
method: "POST",
body: JSON.stringify({something:val})
}
);
if(!response.ok){
throw new Error("Failed to fetch data..");
}
return response.json()
}
but im hosting the app on custom linux server where I have set up nginx which listens on port 80 and propagate it to the next js app which is running on "localhost:3000"
...nextConfig. it all worked before I created with certbot for the nginx a ssl certificate ... now im getting on all fetches CORS error and whe I tried to change in all fetches functions to
"https" ... and tried to rebuild the app im getting errors while building that the fetches cant reach target and that it doesnt exist... probably bcs the next js app is running on http
and the nginx is running on https ... but idk what to do now to make it work..
anyone can help?
asnyc function randomFetch(val: string){
const response = await fetch('http://${process.env.URL}/api/something',
{
cache: "no-store",
method: "POST",
body: JSON.stringify({something:val})
}
);
if(!response.ok){
throw new Error("Failed to fetch data..");
}
return response.json()
}