How do we get a Next.js app to work on App Platform? All my routes to /api are returning 404. The only way I’ve been able to get routing working with Next.js and App Platform has been with getStaticPaths and have it build the routes on npm run export – but you can’t use the getStaticPaths trick with the /api route since it server-side renders at runtime.
Any suggestions, please??
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi @dladendorf, by default the
/api
prefix is dropped from request paths before being forwarding to your service/static site. If you would like Next.js to see the/api
prefix, you can set thepreserve_path_prefix
option:preserve_path_prefix: true
:Hi @dladendorf,
It may be that you added getStaticPaths without getStaticProps. Could you show me how you have set the routes?
Additionally I have found you a good tutorial Deploy a Next.js App to App Platform that I think can help you.
Let me know how this goes. I’d be happy to continue help you.
Sergio Turpín