[GH-ISSUE #3061] [bug]: Self-hosted, oauth authentication doesn't work #999

Closed
opened 2026-03-16 17:59:40 +03:00 by kerem · 3 comments
Owner

Originally created by @Alexis-DevOps on GitHub (May 16, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3061

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Hello,

I'm experiencing an issue trying to self host hoppscotch.

When I connect via google's oauth authentication, I am redirected back to hoppscotch but I am still not connected. The button connect still appears.

Steps to reproduce

I use docker.
Here's my docker-compose.yml file :

version: "3.7"

services:
  # This service runs the backend app in the port 3170
  hoppscotch-backend:
    container_name: hoppscotch-backend
    build:
      dockerfile: packages/hoppscotch-backend/Dockerfile
      context: .
      target: prod
    env_file:
      - ./.env
    command: >
      bash -c "pnpm exec prisma migrate deploy &&
               pnpm run start:prod"

    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:anonymized@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"

  # The main hoppscotch app. This will be hosted at port 3000
  # NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for
  #       the SH admin dashboard server at packages/hoppscotch-selfhost-web/Caddyfile
  hoppscotch-app:
    container_name: hoppscotch-app
    build:
      dockerfile: packages/hoppscotch-selfhost-web/Dockerfile
      context: .
    env_file:
      - ./.env
    depends_on:
      - hoppscotch-backend
    ports:
      - "3000:8080"

  # The Self Host dashboard for managing the app. This will be hosted at port 3100
  # NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for
  #       the SH admin dashboard server at packages/hoppscotch-sh-admin/Caddyfile
  hoppscotch-sh-admin:
    container_name: hoppscotch-sh-admin
    build:
      dockerfile: packages/hoppscotch-sh-admin/Dockerfile
      context: .
    env_file:
      - ./.env
    depends_on:
      - hoppscotch-backend
    ports:
      - "3100:8080"

  # The preset DB service, you can delete/comment the below lines if
  # you are using an external postgres instance
  # This will be exposed at port 5432
  hoppscotch-db:
    image: postgres
    ports:
      - "5432:5432"
    environment:
      POSTGRES_PASSWORD: anonymized
      POSTGRES_DB: hoppscotch

  # Mailcatcher for test purposes
  mailcatcher:
    restart: on-failure
    image: dockage/mailcatcher:0.8.2
    ports:
    - "1080:1080"
    - "1025:1025"

Here is my anonimized .env :

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

# Auth Tokens Config
JWT_SECRET="xxx"
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='xxx'

# Hoppscotch App Domain Config
REDIRECT_URL="http://hoppscotch.mydomain.fr:3000"
WHITELISTED_ORIGINS = "http://hoppscotch.mydomain.fr:3170,http://hoppscotch.mydomain.fr:3000,http://hoppscotch.mydomain.fr:3100"

# Google Auth Config
GOOGLE_CLIENT_ID="xxx"
GOOGLE_CLIENT_SECRET="xxx"
GOOGLE_CALLBACK_URL="http://hoppscotch.mydomain.fr:3170/v1/auth/google/callback"
GOOGLE_SCOPE="email,profile"

# Github Auth Config
GITHUB_CLIENT_ID="************************************************"
GITHUB_CLIENT_SECRET="************************************************"
GITHUB_CALLBACK_URL="http://localhost:3170/v1/auth/github/callback"
GITHUB_SCOPE="user:email"

# Microsoft Auth Config
MICROSOFT_CLIENT_ID="************************************************"
MICROSOFT_CLIENT_SECRET="************************************************"
MICROSOFT_CALLBACK_URL="http://localhost:3170/v1/auth/microsoft/callback"
MICROSOFT_SCOPE="user.read"

# Mailer config
MAILER_SMTP_URL="smtp://localhost:1025"
MAILER_ADDRESS_FROM='"Your favorite administrator" <from@example.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://hoppscotch.mydomain.fr:3000
VITE_SHORTCODE_BASE_URL=http://hoppscotch.mydomain.fr:3000
VITE_ADMIN_URL=http://hoppscotch.mydomain.fr:3100

# Backend URLs
VITE_BACKEND_GQL_URL=http://hoppscotch.mydomain.fr:3170/graphql
VITE_BACKEND_WS_URL=wss://hoppscotch.mydomain.fr:3170/graphql
VITE_BACKEND_API_URL=http://hoppscotch.mydomain.fr:3170/v1

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

When I try to connect the only logs showed from backend are :

hoppscotch-backend     | Query Complexity: 7
hoppscotch-backend     | Query Complexity: 4
hoppscotch-backend     | Query Complexity: 3
hoppscotch-backend     | Query Complexity: 17
hoppscotch-backend     | Query Complexity: 3
hoppscotch-backend     | Query Complexity: 2
hoppscotch-backend     | Query Complexity: 7
hoppscotch-backend     | Query Complexity: 4
hoppscotch-backend     | Query Complexity: 3
hoppscotch-backend     | Query Complexity: 3
hoppscotch-backend     | Query Complexity: 17
hoppscotch-backend     | Query Complexity: 2
hoppscotch-backend     | Query Complexity: 7
hoppscotch-backend     | Query Complexity: 4
hoppscotch-backend     | Query Complexity: 3
hoppscotch-backend     | Query Complexity: 3

Environment

Production

Version

Self-hosted

Originally created by @Alexis-DevOps on GitHub (May 16, 2023). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3061 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior Hello, I'm experiencing an issue trying to self host hoppscotch. When I connect via google's oauth authentication, I am redirected back to hoppscotch but I am still not connected. The button connect still appears. ### Steps to reproduce I use docker. Here's my docker-compose.yml file : ``` version: "3.7" services: # This service runs the backend app in the port 3170 hoppscotch-backend: container_name: hoppscotch-backend build: dockerfile: packages/hoppscotch-backend/Dockerfile context: . target: prod env_file: - ./.env command: > bash -c "pnpm exec prisma migrate deploy && pnpm run start:prod" 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:anonymized@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" # The main hoppscotch app. This will be hosted at port 3000 # NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for # the SH admin dashboard server at packages/hoppscotch-selfhost-web/Caddyfile hoppscotch-app: container_name: hoppscotch-app build: dockerfile: packages/hoppscotch-selfhost-web/Dockerfile context: . env_file: - ./.env depends_on: - hoppscotch-backend ports: - "3000:8080" # The Self Host dashboard for managing the app. This will be hosted at port 3100 # NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for # the SH admin dashboard server at packages/hoppscotch-sh-admin/Caddyfile hoppscotch-sh-admin: container_name: hoppscotch-sh-admin build: dockerfile: packages/hoppscotch-sh-admin/Dockerfile context: . env_file: - ./.env depends_on: - hoppscotch-backend ports: - "3100:8080" # The preset DB service, you can delete/comment the below lines if # you are using an external postgres instance # This will be exposed at port 5432 hoppscotch-db: image: postgres ports: - "5432:5432" environment: POSTGRES_PASSWORD: anonymized POSTGRES_DB: hoppscotch # Mailcatcher for test purposes mailcatcher: restart: on-failure image: dockage/mailcatcher:0.8.2 ports: - "1080:1080" - "1025:1025" ``` Here is my anonimized .env : ``` #-----------------------Backend Config------------------------------# # Prisma Config DATABASE_URL=postgresql://postgres:anonymized@hoppscotch-db:5432/hoppscotch # Auth Tokens Config JWT_SECRET="xxx" 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='xxx' # Hoppscotch App Domain Config REDIRECT_URL="http://hoppscotch.mydomain.fr:3000" WHITELISTED_ORIGINS = "http://hoppscotch.mydomain.fr:3170,http://hoppscotch.mydomain.fr:3000,http://hoppscotch.mydomain.fr:3100" # Google Auth Config GOOGLE_CLIENT_ID="xxx" GOOGLE_CLIENT_SECRET="xxx" GOOGLE_CALLBACK_URL="http://hoppscotch.mydomain.fr:3170/v1/auth/google/callback" GOOGLE_SCOPE="email,profile" # Github Auth Config GITHUB_CLIENT_ID="************************************************" GITHUB_CLIENT_SECRET="************************************************" GITHUB_CALLBACK_URL="http://localhost:3170/v1/auth/github/callback" GITHUB_SCOPE="user:email" # Microsoft Auth Config MICROSOFT_CLIENT_ID="************************************************" MICROSOFT_CLIENT_SECRET="************************************************" MICROSOFT_CALLBACK_URL="http://localhost:3170/v1/auth/microsoft/callback" MICROSOFT_SCOPE="user.read" # Mailer config MAILER_SMTP_URL="smtp://localhost:1025" MAILER_ADDRESS_FROM='"Your favorite administrator" <from@example.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://hoppscotch.mydomain.fr:3000 VITE_SHORTCODE_BASE_URL=http://hoppscotch.mydomain.fr:3000 VITE_ADMIN_URL=http://hoppscotch.mydomain.fr:3100 # Backend URLs VITE_BACKEND_GQL_URL=http://hoppscotch.mydomain.fr:3170/graphql VITE_BACKEND_WS_URL=wss://hoppscotch.mydomain.fr:3170/graphql VITE_BACKEND_API_URL=http://hoppscotch.mydomain.fr:3170/v1 # Terms Of Service And Privacy Policy Links (Optional) VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy ``` When I try to connect the only logs showed from backend are : ``` hoppscotch-backend | Query Complexity: 7 hoppscotch-backend | Query Complexity: 4 hoppscotch-backend | Query Complexity: 3 hoppscotch-backend | Query Complexity: 17 hoppscotch-backend | Query Complexity: 3 hoppscotch-backend | Query Complexity: 2 hoppscotch-backend | Query Complexity: 7 hoppscotch-backend | Query Complexity: 4 hoppscotch-backend | Query Complexity: 3 hoppscotch-backend | Query Complexity: 3 hoppscotch-backend | Query Complexity: 17 hoppscotch-backend | Query Complexity: 2 hoppscotch-backend | Query Complexity: 7 hoppscotch-backend | Query Complexity: 4 hoppscotch-backend | Query Complexity: 3 hoppscotch-backend | Query Complexity: 3 ``` ### Environment Production ### Version Self-hosted
kerem 2026-03-16 17:59:40 +03:00
Author
Owner

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

@Raspout We use secure, HTTP-only cookies for auth in our self-host app, can you try securing your domain over https and trying again?

<!-- gh-comment-id:1551866222 --> @balub commented on GitHub (May 17, 2023): @Raspout We use secure, HTTP-only cookies for auth in our self-host app, can you try securing your domain over https and trying again?
Author
Owner

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

Maybe this will help
https://github.com/hoppscotch/hoppscotch/issues/3060

<!-- gh-comment-id:1561005826 --> @eljump commented on GitHub (May 24, 2023): Maybe this will help https://github.com/hoppscotch/hoppscotch/issues/3060
Author
Owner

@Alexis-DevOps commented on GitHub (May 31, 2023):

I've setup a reverse proxy with nginx in order to have HTTPS and I can now connect to Hoppscotch !
Thanks for your help

<!-- gh-comment-id:1569887782 --> @Alexis-DevOps commented on GitHub (May 31, 2023): I've setup a reverse proxy with nginx in order to have HTTPS and I can now connect to Hoppscotch ! Thanks for your help
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#999
No description provided.