Skip to content
Discussion options

You must be logged in to vote

The issue is in this line, it is making a request directly to localhost:3000, this isn't the port the app will be listening in production.

Instead of making a request in getInitialProps for the /api/pets endpoint, you can:

  1. export this function that the endpoint is using in a way to make it shareable
  2. use this new function in the endpoint, but you can now use it in getServerSideProps (or getStaticProps) too, removing the need for a API call

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@liulanz
Comment options

@rafaelalmeidatk
Comment options

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