[GH-ISSUE #3024] [bug]: OAuth2 and email magic link login functionality is not working in self host mode. #985

Closed
opened 2026-03-16 17:56:58 +03:00 by kerem · 2 comments
Owner

Originally created by @lihkak on GitHub (Apr 28, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3024

Originally assigned to: @mirarifhasan on GitHub.

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

The admin panel login and the login from UI fails to work with both oauth and
email smtp. I am running the hoppscotch-backend service in debug mode using
this docker-compose service definition.

I have attached the masked .env below in this issue.

I am running hoppscotch on a ec2 instance with its IP pointing to a
custom subdomain. The security group has allow all for all inbound and outbound traffic.

  hoppscotch-backend:
    container_name: hoppscotch-backend
    build:
      dockerfile: packages/hoppscotch-backend/Dockerfile
      context: .
      target: prod
    command: >
      bash -c "pnpm exec prisma migrate deploy &&
               pnpm run start:debug"
    env_file:
      - ./.env
    restart: always
    environment:
      # Edit the below line to match your PostgresDB URL if you have an outside DB (make sure to update the .env file as well)
      - DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300
      - PORT=3000
    volumes:
      - ./packages/hoppscotch-backend/:/usr/src/app
      - /usr/src/app/node_modules/
    depends_on:
      - hoppscotch-db
    ports:
      - "3170:3000"

Running the attached docker-compose shows no logs for the google and github
oauth flows except these lines

Query Complexity: 2
Query Complexity: 7
Query Complexity: 4
Query Complexity: 3
Query Complexity: 3
Query Complexity: 17
Query Complexity: 2
Query Complexity: 7
Query Complexity: 3

the email smtp flow throws this error

Query Complexity: 7
Query Complexity: 7
[Nest] 123  - 04/28/2023, 10:12:23 AM   ERROR [ExceptionsHandler] Cannot set headers after they are sent to the client
Error: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:393:5)
    at ServerResponse.setHeader (node:_http_outgoing:607:11)
    at ServerResponse.header (/usr/src/app/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:794:10)
    at ServerResponse.location (/usr/src/app/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:915:15)
    at ServerResponse.redirect (/usr/src/app/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:953:18)
    at authCookieHandler (/usr/src/app/src/auth/helper.ts:75:29)
    at AuthController.verify (/usr/src/app/src/auth/auth.controller.ts:57:22)
    at /usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/router/router-execution-context.js:46:28
    at /usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/router/router-proxy.js:9:17

In both oauth and email auth cases after the flow is completed I am redirected
back to the login page in case of admin page and back to the hoppscotch ui in
case of login from the UI.

Steps to reproduce

env file

# Prisma Config
DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch

# Auth Tokens Config
JWT_SECRET="secret1233"
TOKEN_SALT_COMPLEXITY=10
MAGIC_LINK_TOKEN_VALIDITY= 3
REFRESH_TOKEN_VALIDITY="604800000" # Default validity is 7 days (604800000 ms) in ms
ACCESS_TOKEN_VALIDITY="86400000" # Default validity is 1 day (86400000 ms) in ms
SESSION_SECRET='temp_secret'

# Hoppscotch App Domain Config
REDIRECT_URL="http://custom-subdomain.domain.com:3000"
WHITELISTED_ORIGINS = "http://custom-subdomain.domain.com:3170,http://custom-subdomain.domain.com:3000,http://custom-subdomain.domain.com:3100"

# Google Auth Config
GOOGLE_CLIENT_ID="**************************************************************************"
GOOGLE_CLIENT_SECRET="******************************************************"
GOOGLE_CALLBACK_URL="http://custom-subdomain.domain.com:3170/v1/auth/google/callback"
GOOGLE_SCOPE="email,profile"

# Github Auth Config
GITHUB_CLIENT_ID="*****************************************************"
GITHUB_CLIENT_SECRET="**********************************************************"
GITHUB_CALLBACK_URL="http://custom-subdomain.domain.com:3170/v1/auth/github/callback"
GITHUB_SCOPE="user:email"

# Microsoft Auth Config
MICROSOFT_CLIENT_ID="************************************************"
MICROSOFT_CLIENT_SECRET="************************************************"
MICROSOFT_CALLBACK_URL="http://custom-subdomain.domain.com:3170/v1/auth/microsoft/callback"
MICROSOFT_SCOPE="user.read"

# Mailer config
MAILER_SMTP_URL="smtps://no-reply@domain.com:password@smtp.gmail.com"
MAILER_ADDRESS_FROM='"API Testing" <no-reply@domain.com>'

# Rate Limit Config
RATE_LIMIT_TTL=60 # In seconds
RATE_LIMIT_MAX=100 # Max requests per IP


#-----------------------Frontend Config------------------------------#


# Base URLs
VITE_BASE_URL=http://custom-subdomain.domain.com:3000
VITE_SHORTCODE_BASE_URL=http://custom-subdomain.domain.com:3000
VITE_ADMIN_URL=http://custom-subdomain.domain.com:3100

# Backend URLs
VITE_BACKEND_GQL_URL=http://custom-subdomain.domain.com:3170/graphql
VITE_BACKEND_WS_URL=wss://custom-subdomain.domain.com:3170/graphql
VITE_BACKEND_API_URL=http://custom-subdomain.domain.com:3170/v1

# Terms Of Service And Privacy Policy Links (Optional)
VITE_APP_TOS_LINK=http://docs.hoppscotch.io/support/terms
VITE_APP_PRIVACY_POLICY_LINK=http://docs.hoppscotch.io/support/privacy

Environment

Production

Version

Self-hosted

Originally created by @lihkak on GitHub (Apr 28, 2023). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3024 Originally assigned to: @mirarifhasan on GitHub. ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior The admin panel login and the login from UI fails to work with both oauth and email smtp. I am running the hoppscotch-backend service in debug mode using this docker-compose service definition. I have attached the masked .env below in this issue. I am running hoppscotch on a ec2 instance with its IP pointing to a custom subdomain. The security group has allow all for all inbound and outbound traffic. ``` hoppscotch-backend: container_name: hoppscotch-backend build: dockerfile: packages/hoppscotch-backend/Dockerfile context: . target: prod command: > bash -c "pnpm exec prisma migrate deploy && pnpm run start:debug" env_file: - ./.env restart: always environment: # Edit the below line to match your PostgresDB URL if you have an outside DB (make sure to update the .env file as well) - DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300 - PORT=3000 volumes: - ./packages/hoppscotch-backend/:/usr/src/app - /usr/src/app/node_modules/ depends_on: - hoppscotch-db ports: - "3170:3000" ``` Running the attached docker-compose shows no logs for the google and github oauth flows except these lines ``` Query Complexity: 2 Query Complexity: 7 Query Complexity: 4 Query Complexity: 3 Query Complexity: 3 Query Complexity: 17 Query Complexity: 2 Query Complexity: 7 Query Complexity: 3 ``` the email smtp flow throws this error ``` Query Complexity: 7 Query Complexity: 7 [Nest] 123 - 04/28/2023, 10:12:23 AM ERROR [ExceptionsHandler] Cannot set headers after they are sent to the client Error: Cannot set headers after they are sent to the client at new NodeError (node:internal/errors:393:5) at ServerResponse.setHeader (node:_http_outgoing:607:11) at ServerResponse.header (/usr/src/app/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:794:10) at ServerResponse.location (/usr/src/app/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:915:15) at ServerResponse.redirect (/usr/src/app/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:953:18) at authCookieHandler (/usr/src/app/src/auth/helper.ts:75:29) at AuthController.verify (/usr/src/app/src/auth/auth.controller.ts:57:22) at /usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/router/router-execution-context.js:46:28 at /usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/router/router-proxy.js:9:17 ``` In both oauth and email auth cases after the flow is completed I am redirected back to the login page in case of admin page and back to the hoppscotch ui in case of login from the UI. ### Steps to reproduce # env file ```#-----------------------Backend Config------------------------------# # Prisma Config DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch # Auth Tokens Config JWT_SECRET="secret1233" TOKEN_SALT_COMPLEXITY=10 MAGIC_LINK_TOKEN_VALIDITY= 3 REFRESH_TOKEN_VALIDITY="604800000" # Default validity is 7 days (604800000 ms) in ms ACCESS_TOKEN_VALIDITY="86400000" # Default validity is 1 day (86400000 ms) in ms SESSION_SECRET='temp_secret' # Hoppscotch App Domain Config REDIRECT_URL="http://custom-subdomain.domain.com:3000" WHITELISTED_ORIGINS = "http://custom-subdomain.domain.com:3170,http://custom-subdomain.domain.com:3000,http://custom-subdomain.domain.com:3100" # Google Auth Config GOOGLE_CLIENT_ID="**************************************************************************" GOOGLE_CLIENT_SECRET="******************************************************" GOOGLE_CALLBACK_URL="http://custom-subdomain.domain.com:3170/v1/auth/google/callback" GOOGLE_SCOPE="email,profile" # Github Auth Config GITHUB_CLIENT_ID="*****************************************************" GITHUB_CLIENT_SECRET="**********************************************************" GITHUB_CALLBACK_URL="http://custom-subdomain.domain.com:3170/v1/auth/github/callback" GITHUB_SCOPE="user:email" # Microsoft Auth Config MICROSOFT_CLIENT_ID="************************************************" MICROSOFT_CLIENT_SECRET="************************************************" MICROSOFT_CALLBACK_URL="http://custom-subdomain.domain.com:3170/v1/auth/microsoft/callback" MICROSOFT_SCOPE="user.read" # Mailer config MAILER_SMTP_URL="smtps://no-reply@domain.com:password@smtp.gmail.com" MAILER_ADDRESS_FROM='"API Testing" <no-reply@domain.com>' # Rate Limit Config RATE_LIMIT_TTL=60 # In seconds RATE_LIMIT_MAX=100 # Max requests per IP #-----------------------Frontend Config------------------------------# # Base URLs VITE_BASE_URL=http://custom-subdomain.domain.com:3000 VITE_SHORTCODE_BASE_URL=http://custom-subdomain.domain.com:3000 VITE_ADMIN_URL=http://custom-subdomain.domain.com:3100 # Backend URLs VITE_BACKEND_GQL_URL=http://custom-subdomain.domain.com:3170/graphql VITE_BACKEND_WS_URL=wss://custom-subdomain.domain.com:3170/graphql VITE_BACKEND_API_URL=http://custom-subdomain.domain.com:3170/v1 # Terms Of Service And Privacy Policy Links (Optional) VITE_APP_TOS_LINK=http://docs.hoppscotch.io/support/terms VITE_APP_PRIVACY_POLICY_LINK=http://docs.hoppscotch.io/support/privacy ``` ### Environment Production ### Version Self-hosted
kerem 2026-03-16 17:56:58 +03:00
Author
Owner

@eljump commented on GitHub (May 3, 2023):

#3016
i have the same problem i think

<!-- gh-comment-id:1532737853 --> @eljump commented on GitHub (May 3, 2023): #3016 i have the same problem i think
Author
Owner

@kzachetovb2b commented on GitHub (May 17, 2023):

Hi! i am having the same described issue with [2023.4.3] on self hosted with docker compose
I am redirected back to the login page in case of admin page and back to the hoppscotch ui in
case of login from the UI.
Is there a way how i can troubleshoot and collect some useful logs. I have included

    command: >
      bash -c "pnpm exec prisma migrate deploy &&
               pnpm run start:debug"

but do not see any logs after email workflow

<!-- gh-comment-id:1551257105 --> @kzachetovb2b commented on GitHub (May 17, 2023): Hi! i am having the same described issue with [2023.4.3] on self hosted with docker compose I am redirected back to the login page in case of admin page and back to the hoppscotch ui in case of login from the UI. Is there a way how i can troubleshoot and collect some useful logs. I have included ``` command: > bash -c "pnpm exec prisma migrate deploy && pnpm run start:debug" ``` but do not see any logs after email workflow
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#985
No description provided.