hoarder-app / hoarder

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
https://hoarder.app
GNU Affero General Public License v3.0
6.57k stars 236 forks source link

error: https://next-auth.js.org/errors#no_secret Please define a `secret` in production. r [MissingSecretError]: Please define a `secret` in production. #487

Closed ljq29 closed 1 month ago

ljq29 commented 1 month ago

Docker build,docker compose here:

version: "3.8"
services:
  web:
    # image: ghcr.io/hoarder-app/hoarder-web:${HOARDER_VERSION:-release}
    image: ghcr.nju.edu.cn/hoarder-app/hoarder-web:release
    restart: unless-stopped
    volumes:
      - /volume1/Docker/hoarder/data:/data
    # ports:
    #   - 3000:3000 #修改成自己想要的端口
    expose:
      - 3000
    environment:
      REDIS_HOST: redis
      MEILI_ADDR: http://meilisearch:7700
      DATA_DIR: /data
    networks:
      - network-bridge
      - traefik
    labels:
      # 初始化 traefik
      - "traefik.enable=true"
      - "traefik.docker.network=traefik"
      - "traefik.http.services.${AppName}-backend.loadbalancer.server.scheme=http"
      - "traefik.http.services.${AppName}-backend.loadbalancer.server.port=3000"
      - "traefik.http.routers.${AppName}-ssl.tls.certresolver=le"
      # 设置中间件
      # - "traefik.http.middlewares.gzip.compress=true"
      - "traefik.http.middlewares.${AppName}-redir-https.redirectscheme.scheme=https"
      - "traefik.http.middlewares.${AppName}-redir-https.redirectscheme.permanent=false"

      # http80
      - "traefik.http.routers.${AppName}-web.entrypoints=http"
      - "traefik.http.routers.${AppName}-web.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.${AppName}-web.middlewares=${AppName}-redir-https, gzip"

      # https443
      - "traefik.http.routers.${AppName}-ssl.entrypoints=https"
      - "traefik.http.routers.${AppName}-ssl.tls=true"
      - "traefik.http.routers.${AppName}-ssl.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.${AppName}-ssl.middlewares=gzip"

      # https8443
      - "traefik.http.routers.${AppName}-ssl8443.entrypoints=https8443"
      - "traefik.http.routers.${AppName}-ssl8443.tls=true"
      - "traefik.http.routers.${AppName}-ssl8443.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.${AppName}-ssl8443.middlewares=gzip"
  redis:
    image: redis:7.2-alpine
    restart: unless-stopped
    volumes:
      - redis:/data
    networks:
      - network-bridge
  chrome:
    image: gcr.nju.edu.cn/zenika-hub/alpine-chrome:123
    restart: unless-stopped
    command:
      - --no-sandbox
      - --disable-gpu
      - --disable-dev-shm-usage
      - --remote-debugging-address=0.0.0.0
      - --remote-debugging-port=9222
      - --hide-scrollbars
    networks:
      - network-bridge
  meilisearch:
    # image: getmeili/meilisearch:v1.6
    image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/getmeili/meilisearch:v1.10
    restart: unless-stopped
    environment:
      MEILI_NO_ANALYTICS: "true"
    volumes:
      - meilisearch:/meili_data
    networks:
      - network-bridge
  workers:
    # image: ghcr.io/hoarder-app/hoarder-workers:${HOARDER_VERSION:-release}
    image: ghcr.nju.edu.cn/hoarder-app/hoarder-workers:release
    restart: unless-stopped
    volumes:
      - /volume1/Docker/hoarder/data:/data
    environment:
      REDIS_HOST: redis
      MEILI_ADDR: http://meilisearch:7700
      BROWSER_WEB_URL: http://chrome:9222
      DATA_DIR: /data
      # OPENAI_API_KEY: ...
    networks:
      - network-bridge
    depends_on:
      web:
        condition: service_started

volumes:
  redis:
  meilisearch:

networks:
  network-bridge:
    driver: bridge
  traefik:
    external: true

.env

HOARDER_VERSION=release
NEXTAUTH_SECRET=vQNPMiKQ4cVHM3EjGQm8YN0rG+hIY4erC4rGRuZTiiY=
MEILI_MASTER_KEY=vQNPMiKQ4cVHM3EjGQm8YN0rG+hIY4erC4rGRuZTiiY=
NEXTAUTH_URL=http://localhost:3000

error in web image

error in logs

https://next-auth.js.org/errors#no_secret Please define a `secret` in production. r [MissingSecretError]: Please define a `secret` in production.

    at t.assertConfig (/app/apps/web/.next/server/chunks/8109.js:1:51161)

    at m (/app/apps/web/.next/server/chunks/8109.js:1:44525)

    at async o (/app/apps/web/.next/server/chunks/8109.js:25:20595)

    at async g (/app/apps/web/.next/server/chunks/4685.js:1:8184) {

  code: 'NO_SECRET'

}

Error: There is a problem with the server configuration. Check the server logs for more information.

    at o (/app/apps/web/.next/server/chunks/8109.js:25:20843)

    at async i (/app/apps/web/.next/server/app/page.js:1:2845) {

  digest: '2936418077'

}

Error: There is a problem with the server configuration. Check the server logs for more information.

    at o (/app/apps/web/.next/server/chunks/8109.js:25:20843)

    at async g (/app/apps/web/.next/server/chunks/4685.js:1:8184) {

  digest: '3467703528'

}

Error: There is a problem with the server configuration. Check the server logs for more information.

    at o (/app/apps/web/.next/server/chunks/8109.js:25:20843)

    at async g (/app/apps/web/.next/server/chunks/4685.js:1:8184) {

  digest: '3467703528'

}
MohamedBassem commented 1 month ago

You seem to have removed the env_file attributes from the docker compose, is that intentional?

ljq29 commented 1 month ago

I am using portainer, So I put the environment in the web Instead of env file.

---Original--- From: "Mohamed @.> Date: Sun, Oct 6, 2024 01:24 AM To: @.>; Cc: @.**@.>; Subject: Re: [hoarder-app/hoarder] error:https://next-auth.js.org/errors#no_secret Please define a secret inproduction. r [MissingSecretError]: Please define a secret in production.(Issue #487)

You seem to have removed the env_file attributes from the docker compose, is that intentional?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

MohamedBassem commented 1 month ago

I think with portainer, after you put the env in the web, you still need to add env_file as stack.env.

ljq29 commented 1 month ago

I used to use my way and its work. But in this case it seems failled.

Anyway, I will try your method.

---Original--- From: "Mohamed @.> Date: Sun, Oct 6, 2024 01:27 AM To: @.>; Cc: @.**@.>; Subject: Re: [hoarder-app/hoarder] error:https://next-auth.js.org/errors#no_secret Please define a secret inproduction. r [MissingSecretError]: Please define a secret in production.(Issue #487)

I think with portainer, after you put the env in the web, you still need to add env_file as stack.env.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ljq29 commented 1 month ago

I think with portainer, after you put the env in the web, you still need to add env_file as stack.env.

I finally put like this to resolve problem, instead of define NEXTAUTH_SECRET env in web.

services: web:

image: ghcr.io/hoarder-app/hoarder-web:${HOARDER_VERSION:-release}

image: ghcr.nju.edu.cn/hoarder-app/hoarder-web:release
restart: unless-stopped
volumes:
  - /volume1/Docker/hoarder/data:/data
# ports:
#   - 3000:3000 #修改成自己想要的端口
expose:
  - 3000
environment:
  REDIS_HOST: redis
  MEILI_ADDR: http://meilisearch:7700
  DATA_DIR: /data
  NEXTAUTH_SECRET: "vQNPMiKQ4cVHM3EjGQm8YN0rG+hIY4erC4rGRuZTiiY="
networks:
  - network-bridge
  - traefik