HTTP not s Request:
Answered
Sun bear posted this in #help-forum
Original message was deleted.
Answered by Ray
you could create a route handler and fetch the http endpoint
/api/proxy?url=http://127.0.0.1:5000/result
29 Replies
Original message was deleted

yes, we can make a fetch request in nextjs.
I don't see any problem with the code above yet. could you show more code where do you use
I don't see any problem with the code above yet. could you show more code where do you use
fetchRating
?
@Ray yes, we can make a fetch request in nextjs.
I don't see any problem with the code above yet. could you show more code where do you use `fetchRating`?

Sun bear
i cant use http in nextJS when hosted on vercel. It says it is not allowed

oh do you mean you are trying to make http request on a site running on https?

@Sun bear i cant use http in nextJS when hosted on vercel. It says it is not allowed

So, are you trying to fetch through localhost on production?
How is it possible

Sun bear
I have the page hosted on vercel but the data I need is on a http server

The issue may be that it can't reach your api if it's hosted on your local host and not on the the same

@Sun bear I have the page hosted on vercel but the data I need is on a http server

we can't, because of Mixed Content Security Policy
https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content
https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content
where do you call
fetchRating()
? on page load?
Sun bear
i do it when submiting data to the server

you could create a route handler and fetch the http endpoint
/api/proxy?url=http://127.0.0.1:5000/result
Answer

@Sun bear i do it when submiting data to the server

could you show the code?

Sun bear

could you turn this to server action?
it should be fine if the http request is made on the server side

Sun bear
i put the whole fetch logic in a route once but it did not helped

@Sun bear i put the whole fetch logic in a route once but it did not helped

oh can I try to fetch the endpoint?

Sun bear
server is currently offline

nm Im trying to fetch another endpoint on http

Sun bear
i am waiting for my partner to power it up

let me deploy it to vercel
yes you can't make http request on a https site

Sun bear
xD 🙂

try fetch your api on server side
I can't find a http endpoint to test lol
the one I was trying redirect the request to https
or run your server on https

Sun bear
thanks anyway 🙂