I created an API with NextJS in the API folder. Now I want to fetch the data from that API in the getServerSideProps function.
const res = await fetch(`localhost:3000/api/playlist`);
But I get an error that says that it only supports HTTPS protocols.
Server Error
TypeError: Only HTTP(S) protocols are supported
This error happened while generating the page. Any console logs will be displayed in the terminal window.
How can I fetch the data from the NextJS API on my localhost? Thanks for you helping out!
I found the problem, I forgot to add http:// in front of the URL.
The code would then look like this:
const res = await fetch(`http://localhost:3000/api/playlist`);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With