Skip to content

How to deploy a next.js app to google app engine (GAE) #12474

Answered by bradrisse
Pixelatex asked this question in Help
Discussion options

You must be logged in to vote

next.config.js

module.exports = {
  distDir: 'build',
}
  • Google App Engine doesn't recognize .next folder so you need to change the folder from .next to build using the distDir parameter in the next.config.js

app.yaml

env: standard
runtime: nodejs12
service: default

handlers:
  - url: /.*
    secure: always
    script: auto
  • The newest version of nextjs has dependencies that require nodejs12, so setting the runtime to nodejs12 fixes that issue
  • the /.* ensures access to all folders and sub folders within the build folder
  • secure always ensures https is used
  • script auto tells GAE to rely on nextjs to indicate what files to load instead of index.js

package.json -> scripts

"start": "next …

Replies: 8 comments 19 replies

Comment options

You must be logged in to vote
4 replies
@FBosler
Comment options

@ollyde
Comment options

@christianguevara
Comment options

@jonolayton
Comment options

Answer selected by leerob
Comment options

You must be logged in to vote
4 replies
@sriramveeraghanta
Comment options

@bradrisse
Comment options

@forest1206
Comment options

@paulineramos
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@dipeshhkc
Comment options

@anthwinter
Comment options

@Khalilw1
Comment options

Comment options

You must be logged in to vote
3 replies
@dipeshhkc
Comment options

@forest1206
Comment options

@bradrisse
Comment options

Comment options

You must be logged in to vote
1 reply
@christianguevara
Comment options

Comment options

You must be logged in to vote
4 replies
@Nickprovs
Comment options

@knowbody
Comment options

@Nickprovs
Comment options

@knowbody
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet