peppermint icon indicating copy to clipboard operation
peppermint copied to clipboard

Web Page does not load After Sign in

Open jpcapone opened this issue 3 years ago • 2 comments

After I deploy the system using the docker compose example, i am unable to connect after logging in. The error is can't reach this page. In the docker container log I see this in the logs: The following migrations have been applied:

migrations/ └─ 20220129233509_/ └─ migration.sql └─ 20220130122101_/ └─ migration.sql └─ 20220130225732_/ └─ migration.sql

All migrations have been successfully applied. Done in 1.84s. yarn run v1.22.19 $ prisma generate Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (3.7.0 | library) to ./node_modules/@prisma/client in 188ms You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

warn Versions of [email protected] and @prisma/[email protected] don't match. This might lead to unexpected behavior. Please make sure they have the same version. ┌─────────────────────────────────────────────────────────┐ │ Update available 3.14.0 -> 4.3.1 │ │ │ │ This is a major update - please follow the guide at │ │ https://pris.ly/d/major-version-upgrade │ │ │ │ Run the following to update │ │ yarn add --dev prisma@latest │ │ yarn add @prisma/client@latest │ └─────────────────────────────────────────────────────────┘ Done in 3.35s. yarn run v1.22.19 $ prisma db seed Environment variables loaded from .env Running seed command node prisma/seed.js ... { admin: { id: 1, createdAt: 2022-09-11T20:22:19.258Z, updatedAt: 2022-09-11T20:22:19.258Z, name: 'admin', password: '$2b$10$BFmibvOW7FtY0soAAwujoO9y2tIyB7WEJ2HNq9O7zh9aeejMvRsKu', email: '[email protected]', isAdmin: true }, internal: { id: 1, createdAt: 2022-09-11T20:22:19.264Z, updatedAt: 2022-09-11T20:22:19.264Z, name: 'internal', email: '[email protected]', contactName: 'admin', number: '123456789', notes: null } }

🌱 The seed command has been executed. Done in 1.26s. yarn run v1.22.19
$ next start ready - started server on 0.0.0.0:5000, url: http://localhost:5000 info - Loaded env from /app/.env warn - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled [next-auth][error][CLIENT_FETCH_ERROR] https://next-auth.js.org/errors#client_fetch_error request to http://peppermint.jwtsolutions.co/api/auth/csrf failed, reason: read ECONNRESET { error: { message: 'request to http://peppermint.jwtsolutions.co/api/auth/csrf failed, reason: read ECONNRESET', stack: 'FetchError: request to http://peppermint.jwtsolutions.co/api/auth/csrf failed, reason: read ECONNRESET\n' + ' at ClientRequest. (/app/node_modules/node-fetch/lib/index.js:1461:11)\n' + ' at ClientRequest.emit (events.js:400:28)\n' + ' at Socket.socketErrorListener (_http_client.js:475:9)\n' + ' at Socket.emit (events.js:400:28)\n' + ' at emitErrorNT (internal/streams/destroy.js:106:8)\n' + ' at emitErrorCloseNT (internal/streams/destroy.js:74:3)\n' + ' at processTicksAndRejections (internal/process/task_queues.js:82:21)', name: 'FetchError' }, path: 'csrf', header: { host: 'peppermint.jwtsolutions.co:5000', connection: 'keep-alive', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.33', accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9', referer: 'http://peppermint.jwtsolutions.co:5000/', 'accept-encoding': 'gzip, deflate', 'accept-language': 'en-US,en;q=0.9', cookie: 'next-auth.csrf-token=2185a6d7a3eb7be7611fbe8167fd45089e6cd0d28e6f18ad0807e51d500131f3%7C21321598a39c68df3f039ea0d6e48909f009cadf61e3d89e44c0365c6ec2e7b0; next-auth.callback-url=http%3A%2F%2Fpeppermint.jwtsolutions.co%3A5000%2F' }, message: 'request to http://peppermint.jwtsolutions.co/api/auth/csrf failed, reason: read ECONNRESET' }

I notice that the instructions say to go the base url which doesnt load. I added port 80 to the client container just to test it and it was still no go. however I can connect when I go to 'http://peppermint.jwtsolutions.co:5000/', I am prompted to log in but after that I am redirected to a page that does not load.

Any suggestions would be appreciated. Any suggestions would be appreciated.

jpcapone avatar Sep 11 '22 20:09 jpcapone

can you post your docker compose file please

potts99 avatar Sep 11 '22 21:09 potts99

Thanks for getting back to me so quickly.

version: "3.1"

services: postgres: container_name: postgres image: postgres:latest restart: always volumes: - ./docker-data/db:/data/db environment: POSTGRES_USER: peppermint POSTGRES_PASSWORD: 1234 POSTGRES_DB: peppermint

client: container_name: peppermint image: pepperlabs/peppermint:latest ports: - 5000:5000 restart: on-failure depends_on: - postgres environment: PORT: 5000 DB_USERNAME: peppermint DB_PASSWORD: 1234 DB_HOST: 'postgres' BASE_URL: "http://peppermint.jwtsolutions.co"

jpcapone avatar Sep 11 '22 21:09 jpcapone

Did we have any updates on this issue? I can provide more detail if needed.

jpcapone avatar Oct 20 '22 02:10 jpcapone

UPDATE - I changed the bse url to peppermint (removing the jwtsolutions.co from the docker compose file) and redeployed the container and the error is slightly different:

yarn run v1.22.19 $ prisma migrate deploy Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma Datasource "db": PostgreSQL database "peppermint", schema "public" at "postgres:5432"

3 migrations found in prisma/migrations

No pending migrations to apply. Done in 2.22s. yarn run v1.22.19 $ prisma generate Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (3.7.0 | library) to ./node_modules/@prisma/client in 270ms You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

warn Versions of [email protected] and @prisma/[email protected] don't match. This might lead to unexpected behavior. Please make sure they have the same version. ┌─────────────────────────────────────────────────────────┐ │ Update available 3.14.0 -> 4.5.0 │ │ │ │ This is a major update - please follow the guide at │ │ https://pris.ly/d/major-version-upgrade │ │ │ │ Run the following to update │ │ yarn add --dev prisma@latest │ │ yarn add @prisma/client@latest │ └─────────────────────────────────────────────────────────┘ Done in 5.75s. yarn run v1.22.19 $ prisma db seed Environment variables loaded from .env Running seed command node prisma/seed.js ... { admin: { id: 1, createdAt: 2022-09-11T22:34:35.429Z, updatedAt: 2022-09-11T22:34:35.429Z, name: 'admin', password: '$2b$10$BFmibvOW7FtY0soAAwujoO9y2tIyB7WEJ2HNq9O7zh9aeejMvRsKu', email: '[email protected]', isAdmin: true }, internal: { id: 1, createdAt: 2022-09-11T22:34:35.441Z, updatedAt: 2022-09-11T22:34:35.441Z, name: 'internal', email: '[email protected]', contactName: 'admin', number: '123456789', notes: null } }

🌱 The seed command has been executed. Done in 1.71s. yarn run v1.22.19
$ next start ready - started server on 0.0.0.0:5000, url: http://localhost:5000 info - Loaded env from /app/.env warn - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled [next-auth][error][CLIENT_FETCH_ERROR] https://next-auth.js.org/errors#client_fetch_error request to http://peppermint/api/auth/csrf failed, reason: connect ECONNREFUSED 172.19.0.3:80 { error: { message: 'request to http://peppermint/api/auth/csrf failed, reason: connect ECONNREFUSED 172.19.0.3:80', stack: 'FetchError: request to http://peppermint/api/auth/csrf failed, reason: connect ECONNREFUSED 172.19.0.3:80\n' + ' at ClientRequest. (/app/node_modules/node-fetch/lib/index.js:1461:11)\n' + ' at ClientRequest.emit (events.js:400:28)\n' + ' at Socket.socketErrorListener (_http_client.js:475:9)\n' + ' at Socket.emit (events.js:400:28)\n' + ' at emitErrorNT (internal/streams/destroy.js:106:8)\n' + ' at emitErrorCloseNT (internal/streams/destroy.js:74:3)\n' + ' at processTicksAndRejections (internal/process/task_queues.js:82:21)', name: 'FetchError' }, path: 'csrf', header: { host: 'peppermint:5000', connection: 'keep-alive', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.47', accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9', referer: 'http://peppermint:5000/', 'accept-encoding': 'gzip, deflate', 'accept-language': 'en-US,en;q=0.9', cookie: 'next-auth.csrf-token=2d5b5efc88b8f497122be1e6ecb749d311bfebd6d6c9e7487468096616615392%7C28d533e0bea204b3b8c00fa92cbfec2c7536b35e12b7960ae07b13c338747560; next-auth.callback-url=http%3A%2F%2Fpeppermint%3A5000%2F' }, message: 'request to http://peppermint/api/auth/csrf failed, reason: connect ECONNREFUSED 172.19.0.3:80' }
d

jpcapone avatar Oct 20 '22 03:10 jpcapone

Did we have any updates on this issue? I can provide more detail if needed.

Did you ever set up a reverse proxy?

potts99 avatar Oct 20 '22 08:10 potts99

I use nginx proxy manager but I haven't set it up for this instance just yet. I wanted to get it working before implementing the reverse proxy.

jpcapone avatar Oct 20 '22 11:10 jpcapone

You need to set up the reverse proxy, then will work on your sub directory, i have no issues

potts99 avatar Oct 20 '22 14:10 potts99

I am having a similar issue on a local network setup. Issue #114

--edit-- Please disregard. My issue was completely unrelated.

BobHassok avatar Nov 09 '22 20:11 BobHassok

I know that this issue is old, but for anyone looking to resolve this in the future, the issue comes from the final line of the error.

},
message: 'request to http://peppermint/api/auth/csrf failed, reason: connect ECONNREFUSED 172.19.0.3:80'
}

Here you can see that the error is ECONNREFUSED 172.19.0.3:80, in the end users config the clients base URL is BASE_URL: "http://peppermint.jwtsolutions.co/". which is not 172.19.0.3:80. To resolve this issue quickly, set your base url to include the port as well.

The proper way to resolve it would be probably building a reverse proxy that would forward traffic from port 80 to the port 5000.

ofgrenudo avatar Apr 14 '23 15:04 ofgrenudo

@ofgrenudo thank you for this

Will write some more docs around this

potts99 avatar Jun 11 '23 14:06 potts99

With the new backend api this should now no longer be an issue

potts99 avatar Sep 28 '23 09:09 potts99