Reputation: 11837
Please see the attachment, it shows the folder structure, and the "404" error I am getting when I try to fetch the api. When I run the same api via postman it works fine. But within the nextjs ecosystem, I get a 404. Is there a config issue perhaps I am missing.
Upvotes: 2
Views: 1144
Reputation: 8624
From the doc https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering
Note: You should not use fetch() to call an API route in getServerSideProps. Instead, directly import the logic used inside your API route. You may need to slightly refactor your code for this approach. Fetching from an external API is fine!
Upvotes: 2