Skip to content

How to setup api routes urls for production? #48793

Closed Answered by icyJoseph
thanosoncode asked this question in Help
Discussion options

You must be logged in to vote

This sounds like you are trying to reach to an api route from within the server. That's a bad idea, it means, even if you fixed it, you'll do an extra jump out to the internet and back to your server.

From the docs:

It can be tempting to reach for an API Route when you want to fetch data from the server, then call that API route from getServerSideProps. This is an unnecessary and inefficient approach, as it will cause an extra request to be made due to both getServerSideProps and API Routes running on the server.

Although that was written for GetServerSideProps, it applies to Server Components too.

For what is worth, another framework, Nuxt, has a special $fetch function that can skip …

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@kirilkirkov
Comment options

@plus7c
Comment options

@ClydSpyd
Comment options

@nicKondratiev
Comment options

@ahmedtarekabd
Comment options

Answer selected by thanosoncode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
7 participants