next.js: Dynamic catch-all routes not supported in Google App Engine

Issue with filename-name causing deploy error in Google App Engine

Describe the bug

I’ve had a nextJS app running in the Google App Engine enviroment for a while. Works splendid and fast - however, I added a dynamic route and now I am unable to deploy due to the filename being unsupported (due to the 3 dots).

Error from the Gcloud CLI:

ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: Filename cannot contain '.', '..', '\r', start with '-', '_ah/', or '\n': pages/[...slug]/index.js.

One fix could be using underscore or similar instead, like “[___slug]”

To Reproduce

Deploy the app to Google App Engine using any boilerplate configuration for app.yaml with a dynamic catch all route. Use below example and add a catch-all page.

https://github.com/superbmeteor/nextjs-gae-demo

Expected behavior

Should deploy successfully.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 16
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Same problem here! It’s blocking our project at the moment.

I’m running into this problem right now as well. Any known workarounds would be greatly appreciated

@Timer Google has fixed this on their end now. Closing issue.

I made the following workaround and it seems to work fine.

"gcp-predeploy": "find .next -name '\\[...*' -exec bash -c 'mv \"$1\" \"${1/.../@@@}\"' -- {} \\;",
"gcp-build": "find .next -name '\\[@@@*' -exec bash -c 'mv \"$1\" \"${1/@@@/...}\"' -- {} \\;",
"start": "next start -p ${PORT:-3000}",

Invoke yarn gcp-predeploy after building and before deploying to change ... to @@@ for uploading. The gcp-build steps renames it back on the app-engine instance. A small disadvantage of having a gcp-build step is that all dependencies are installed (including dev) for the gcp-build step and then cleared and then again for the start step, slightly increasing instance startup time. Note that we cannot rename inside the start script as the file system is read-only at that time.

I’m also having this problem. The problem only occurs on the App Engine Standard environment.