From 1275e38c19dbd000c5b949f7c979a8616a55997b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Wed, 10 Jan 2024 21:03:28 +0100 Subject: [PATCH] README: expalining HOSTNAME issue --- README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d5c771c..0962eb9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -# ToDo -* year pagination - # Authentication Authentication consists of the following parts: * `next-auth` boilerplate @@ -32,10 +29,20 @@ The image will be stored in the local Docker instance. ## Deploying Docker service Run the following command: ```bash -HOSTNAME=0.0.0.0 \ -NEXTAUTH_URL=https://rezije.app \ -PORT=3001 \ docker stack deploy \ -c docker-compose-deploy.yml \ utility-bills-tracker -``` \ No newline at end of file +``` + +# Implementation details +## Issues with HOSTNAME +When deplyed via docker and published via Cloudflare there's an issue with `HOSTNAME` env variable: +* if left unset, the server will use IP address assigned to container by Docker and **will not accept connections from outside** +* if set to "0.0.0.0" the server will serve static pages, but will *reject API calls when submitting form* +* if set to "rezije.app" the server will not start since the IP address it resolves with the given FQDN does not match any of the IP addresses assigned to the container + +So there are the following issues: +* server will not accept external request - can be fixed by setting `HOSTNAME` to `0.0.0.0` +* server rejects API requests - can be fixed by adding `serverActions.allowedOrigins` option to `nextjs.config.js` file + +So these are the fixes which were implemented in order to be able to run server in production. \ No newline at end of file