Question

Requesting Next.js web service through public route returns 404 error on Digital Ocean App Platform

Problem

I am setting up an App Platform on Digital Ocean using a Strapi web service component as CMS and a Next.js web service component as Front-End. Strapi is accessible on the route /api and Next.js on /sporus. According to the runtime logs building and deployment are both successful and no errors are shown. When I try to access my Next.js web service through the route /sporus I am met with a 404 screen. Strapi on /api is working including the admin panels and requests.

Goal

Next.js Webservice is accessible through the /sporus route and does not return a 404.

##What I’ve tried

Files

next.config.js

const domains = (process.env.APP_URL) ? [process.env.APP_URL] : ['localhost'];

module.exports = {
  reactStrictMode: false,
  images: {
    domains: domains,
  },
  basePath: process.env.BASE_PATH,
}

env variables

App wide:

- key: STRAPI_URL
  scope: RUN_AND_BUILD_TIME
  value: ${APP_URL}/api
- key: NEXT_PUBLIC_STRAPI_URL
  scope: RUN_AND_BUILD_TIME
  value: ${APP_URL}/api
- key: DATABASE_URL
  scope: RUN_AND_BUILD_TIME
  value: ${db.DATABASE_URL}
- key: APP_URL
  scope: RUN_AND_BUILD_TIME
  value: ${APP_URL}

Next component specific:

key: NEXT_URL
    scope: RUN_AND_BUILD_TIME
    value: ${APP_URL}/sporus
  - key: BASE_PATH
    scope: RUN_AND_BUILD_TIME
    value: /sporus

N.B.

I have very experience with D.G. App Platform & Next.js or deploying node.js servers in general. Most of my projects I run locally so I apologise if this question isn’t very descriptive. All additional debugging steps or general tips are welcome.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

So the answer is quite simpel. The App Platform already routes to /sporus. Adding /sporus to the baseUrl will create a double route making the app accesible on /sporus/sporus. Removing baseUrl from next.config.js fixes the issue.