From e42f3382b09005581c7e5c71d71ecff69f4b5cf3 Mon Sep 17 00:00:00 2001 From: weaponsforge Date: Sun, 14 Jul 2024 19:40:41 +0800 Subject: [PATCH 1/2] fix: add client env var to enable nextjs hot reload on docker desktop, #137 --- client/.env.example | 24 +++++++++++++----------- client/README.md | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client/.env.example b/client/.env.example index b97f2fa..597f351 100644 --- a/client/.env.example +++ b/client/.env.example @@ -1,11 +1,13 @@ -NEXT_PUBLIC_BASE_PATH='' -NEXT_PUBLIC_BASE_API_URL=http://localhost:3001 -NEXT_PUBLIC_FIREBASE_WEB_API_KEY=AIzaSyDAZxPcy_4XMVcZJ0nIupEGBcGZoABlNU4 -NEXT_PUBLIC_FIREBASE_WEB_AUTHDOMAIN=myphonebook-app-dev.firebaseapp.com -NEXT_PUBLIC_FIREBASE_WEB_PROJECT_ID=myphonebook-app-dev -NEXT_PUBLIC_FIREBASE_WEB_STORAGE_BUCKET=myphonebook-app-dev.appspot.com -NEXT_PUBLIC_FIREBASE_WEB_MESSAGING_SENDER_ID=458788271773 -NEXT_PUBLIC_FIREBASE_WEB_APP_ID=1:458788271773:web:a3c1edf29f5b86da8f4674 -NEXT_PUBLIC_FIREBASE_WEB_MEASUREMENT_ID=G-64M5K063SC -NEXT_PUBLIC_RANDOM_JOKE_API=https://v2.jokeapi.dev/joke/Misc?format=json&safe-mode&type=single -NEXT_PUBLIC_MEDIA_BG1=https://firebasestorage.googleapis.com/v0/b/myphonebook-app.appspot.com/o/assets%2Fimages%2Fpexels-pixabay-101529.jpg?alt=media&token=a7c555b7-1ddb-43cb-82ec-fe9048c6d007 \ No newline at end of file +NEXT_PUBLIC_BASE_PATH='' +NEXT_PUBLIC_BASE_API_URL=http://localhost:3001 +NEXT_PUBLIC_FIREBASE_WEB_API_KEY=AIzaSyDAZxPcy_4XMVcZJ0nIupEGBcGZoABlNU4 +NEXT_PUBLIC_FIREBASE_WEB_AUTHDOMAIN=myphonebook-app-dev.firebaseapp.com +NEXT_PUBLIC_FIREBASE_WEB_PROJECT_ID=myphonebook-app-dev +NEXT_PUBLIC_FIREBASE_WEB_STORAGE_BUCKET=myphonebook-app-dev.appspot.com +NEXT_PUBLIC_FIREBASE_WEB_MESSAGING_SENDER_ID=458788271773 +NEXT_PUBLIC_FIREBASE_WEB_APP_ID=1:458788271773:web:a3c1edf29f5b86da8f4674 +NEXT_PUBLIC_FIREBASE_WEB_MEASUREMENT_ID=G-64M5K063SC +NEXT_PUBLIC_RANDOM_JOKE_API=https://v2.jokeapi.dev/joke/Misc?format=json&safe-mode&type=single +NEXT_PUBLIC_MEDIA_BG1=https://firebasestorage.googleapis.com/v0/b/myphonebook-app.appspot.com/o/assets%2Fimages%2Fpexels-pixabay-101529.jpg?alt=media&token=a7c555b7-1ddb-43cb-82ec-fe9048c6d007 +# Uncomment these 2 CHOKIDAR lines if using Docker Desktop and WSL2 on Windows OS +# WATCHPACK_POLLING=true \ No newline at end of file diff --git a/client/README.md b/client/README.md index 7586f0e..6530116 100644 --- a/client/README.md +++ b/client/README.md @@ -54,6 +54,7 @@ The following dependecies are used for this project. Feel free to experiment usi | NEXT_PUBLIC_FIREBASE_WEB_MEASUREMENT_ID | Firebase web measurement ID from the Firebase Project Settings configuration file. | | NEXT_PUBLIC_MEDIA_BG1 | Firebase storage download URL of the hi-resolution asset file "loginBgResized.jpg" | | NEXT_PUBLIC_RANDOM_JOKE_API | Access URL to the JokeAPI, a REST API that serves uniformly and well formatted jokes. | + | WATCHPACK_POLLING | Enables hot reload on NextJS apps (tested on NextJS v13.2.1) running inside Docker containers on a Windows host. Set it to `true` if running Docker Desktop with WSL2 on a Windows OS.| ## Firebase Setup and Configuration From a58d077cd67ba38f2190448a127eaa5a752c3534 Mon Sep 17 00:00:00 2001 From: weaponsforge Date: Sun, 14 Jul 2024 19:52:30 +0800 Subject: [PATCH 2/2] fix: enable nodemon hot reload in docker desktop, #137 --- server/.env.example | 33 ++++++++++++++++++--------------- server/README.md | 5 +++-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/server/.env.example b/server/.env.example index 1bb4be1..07ddeb3 100644 --- a/server/.env.example +++ b/server/.env.example @@ -1,15 +1,18 @@ -ALLOW_CORS=1 -ALLOWED_ORIGINS=http://localhost:3000,https://my-phonebook-test.web.app -API_RATE_LIMIT=300 -CLIENT_WEBSITE_URL=http://localhost:3000 -EMAIL= -CLIENT_USER= -CLIENT_ID= -CLIENT_SECRET= -REFRESH_TOKEN= -REDIRECT_URI=https://developers.google.com/oauthplayground -VERCEL_TOKEN= -VERCEL_ORG_ID= -VERCEL_PROJECT_ID= -FIREBASE_SERVICE_ACC= -FIREBASE_PRIVATE_KEY= \ No newline at end of file +ALLOW_CORS=1 +ALLOWED_ORIGINS=http://localhost:3000,https://my-phonebook-test.web.app +API_RATE_LIMIT=300 +CLIENT_WEBSITE_URL=http://localhost:3000 +EMAIL= +CLIENT_USER= +CLIENT_ID= +CLIENT_SECRET= +REFRESH_TOKEN= +REDIRECT_URI=https://developers.google.com/oauthplayground +VERCEL_TOKEN= +VERCEL_ORG_ID= +VERCEL_PROJECT_ID= +FIREBASE_SERVICE_ACC= +FIREBASE_PRIVATE_KEY= +# Uncomment these 2 CHOKIDAR lines if using Docker Desktop and WSL2 on Windows OS +# CHOKIDAR_USEPOLLING=true +# CHOKIDAR_INTERVAL=1000 \ No newline at end of file diff --git a/server/README.md b/server/README.md index cbc4223..eea2c2e 100644 --- a/server/README.md +++ b/server/README.md @@ -34,6 +34,7 @@ The following dependecies are used for this project. Feel free to experiment usi | ALLOW_CORS | Allow Cross-Origin Resource Sharing (CORS) on the API endpoints.

Default value is `1`, allowing access to domains listed in `ALLOWED_ORIGINS`.
Setting to `0` will make all endpoints accept requests from all domains, including Postman. | | ALLOWED_ORIGINS | IP/domain origins in comma-separated values that are allowed to access the API if `ALLOW_CORS=1`.
Include `http://localhost:3000` by default to allow CORS access to the **/client** app. | | API_RATE_LIMIT | It's the maximum number of allowed API requests on the server per `API_WINDOW_MS_MINUTES`.
Users will receive a `429 - Too many requests` server error after hitting the limit.
The limit will reset after API_WINDOW_MS_MINUTES minutes, after which users can resume making API requests. | + | CLIENT_WEBSITE_URL | Online base URL of the frontend website i.e., `http://localhost:3000` | | EMAIL, CLIENT_USER | Google email configured for sending email and OAuth2 | | CLIENT_ID | Google OAuth2 client ID. | | CLIENT_SECRET | Google OAuth2 client secret. | @@ -41,8 +42,8 @@ The following dependecies are used for this project. Feel free to experiment usi | REDIRECT_URI | Redirect URI for the Google OAuth2 exchange.
Default value is https://developers.google.com/oauthplayground | | FIREBASE_SERVICE_ACC | The project's private key file contents, condensed into one line and minus all whitespace characters.

The service account JSON file is generated from the Firebase project's **Project Settings** page, on **Project Settings** -> **Service accounts** -> **Generate new private key** | | FIREBASE_PRIVATE_KEY | The `private_key` entry from the service account JSON file.
**NOTE:** Experiment wrapping this value in double-quotes on WINDOWS OS localhost. Some systems may or may not require the double-quotes (i.e., Ubuntu).
| - | FIREBASE_WEB_API_KEY | | - | CLIENT_WEBSITE_URL | | + | CHOKIDAR_USEPOLLING | Enables hot reload on `nodemon` running inside Docker containers on a Windows host. Set it to `true` if running Docker Desktop with WSL2 on a Windows OS. | + | CHOKIDAR_INTERVAL | Chokidar polling interval. Set it along with `CHOKIDAR_USEPOLLING=true` if running Docker Desktop with WSL2 on a Windows OS. Default value is `1000`. | 4. Run the localhost express web server for development:
`npm run dev`