Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

node_modules
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.next/**
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.18.0
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
This git is a complementary to my post at https://medium.com/@daveteu/nextjs-with-google-cloud-functions-in-10-minutes-47f88e6ac27a

**Dependencies**
Node 16

**Download the git and install**

npm install
Expand All @@ -18,10 +21,25 @@ After installation
gcloud init
The above 2 commands will authenticate you and help you create new project.

**Google Cloud Console Setup**
Create a new project in Google Cloud (or select an existing one), and go to the API Library. Make sure the following APIs/services are enabled for your project:

* Cloud Functions API
* Cloud Deployment Manager V2 API
* Cloud Build API
* Cloud Storage
* Cloud Logging API

**Deployment**

Specify the project ID that will be used when you deploy. Retrieve the Google Cloud project ID from the console and :

* **Either** set it on the command line by running `gcloud config set project PROJECT_ID`
* **... or** update the `deploy` script in package.json to include a `--project PROJECT_ID` argument

After editing next.config.js build and deploy your project (to get your url)

npm run build
npm run deploy

After getting the url for your functions, edit next.config.js with the url to your function and run the 2 commands again to get your paths all updated and deploy.
After getting the url for your functions, edit next.config.js with the url to your function and run the 2 commands again to get your paths all updated and deploy.
File renamed without changes.
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const isProd = process.env.NODE_ENV === 'production'
module.exports = {
target: 'serverless',
assetPrefix: isProd ? 'https://asia-east2-nextjs-serverless.cloudfunctions.net/nextjs' : '',
}
assetPrefix: isProd ? 'https://us-central1-react-test-389022.cloudfunctions.net/nextjs' : '',
}
Loading