You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: LEARNING.md
+18-7Lines changed: 18 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,34 +25,45 @@ const nextConfig = {
25
25
26
26
exportdefaultnextConfig;
27
27
```
28
-
29
28
> [!NOTE]
30
29
> When using `output: 'export'` instead of `output: 'standalone'`, Nextjs will throw the runtime Error `Page "/[network]/page" is missing exported function "generateStaticParams()", which is required with "output: export" config.` because of the use of the dynamic route `[network]`.
31
30
32
-
### 2. Add the environment variables to Github
31
+
### 2. Update `package.json` for `output: 'standalone'`
32
+
In `package.json`, update the `"build"` and `"start"` commands of the `"scripts"` field:
**Without this `start` command the page will 404!**
42
+
Without the `cp` command, the Github Pages URL will not find any CSS files. But note that `cp` will not run on Windows, so if you use Windows you should still manually copy these 2 folders after running `npm run build`. This is not a problem for Github Pages though, since it deploys to Linux.
43
+
44
+
### 3. Add the environment variables to Github
33
45
- On Github, navigate to the `Settings` tab of your project, and select `Environments` from the menu on the left-hand side.
34
46
- Select the`github-pages` environment, and under `Environment secrets`, click `Add environment secret` and add `REACT_APP_ALCHEMY_API_KEY` and its value.
35
47
- Click `Add environment secret` again and add `REACT_APP_ETHERSCAN_API_KEY` and its value.
36
48
37
-
### 3. Activate GitHub Pages for Repository
49
+
### 4. Activate GitHub Pages for Repository
38
50
- Now, still under the `Settings` tab of your project, select `Pages` from the menu on the left-hand side.
39
51
- Locate the `Source` dropdown, which is likely set to `Deploy from a branch`.
40
52
- Click `Deploy from a branch` and switch it to `Github Actions`.
41
53
- Click `Configure` in the Github Actions field, which will take you to a `/.github/workflows/nextjs.yml` action configuration file.
42
-
- In this file, we need to add the API keys to the build step, as well as copy some extra folders to the build output because of the `output: 'standalone'`. Find the following text:
54
+
- In this file, we need to add the API keys to the build step. Find the following text:
43
55
```yml
44
56
- name: Build with Next.js
45
57
run: ${{ steps.detect-package-manager.outputs.runner }} next build
46
58
```
47
-
Now, add `&& cp -r ./public ./.next/standalone/ && cp -r ./.next/static ./.next/standalone/.next/` to the build command, and add the following `env` section:
0 commit comments