Strapi v4 on Google App Engine

It’s important to realise that with App Engine, each service is typically ‘concealed’ behind what Google calls an ‘ingress’ (virtual server with proxy-pass rules). When configuring and accessing, one ‘should’ therefore have a forwarding rule in dispatch.yaml. There’s a default rule that forwards everything else to the ‘default’ service. If there’s no other application service, and you configure Strapi as your default service, that default rule will still forward to the Strapi service, which can create confusion - especially if you configure the Strapi ‘public URL’ inappropriately.

If you look back at the description I gave, you will see that the Strapi instance is not the default service and is configured with a PUBLIC_URL value that includes the ‘prefix’ that I then used in dispatch.yaml. This is important, so that any URL generated within Strapi (e.g. for 3rd party sign-on) will route correctly when accessed from outside the GAE environment - i.e. through the ingress layer.

If you want to add a prefix route segment, it is essential that it is reflected in both the PUBLIC_URL value and dispatch.yaml. (And that you remove it with middleware, when a request reaches Strapi.) But if you have configured Strapi as the default service in GAE, you must realise that it can also be accessed without that prefix. So if you configure the PUBLIC_URL value without the prefix, any generated URL will still reach Strapi.

The REST API prefix only replaces the default string of ‘api’ with something else: it doesn’t change any other part of the generated URLs or routes.