本地调试webapp-conversation api链接报401 #204

Closed
opened 2026-02-21 17:26:22 -05:00 by yindo · 4 comments
Owner

Originally created by @xiaoxuan220 on GitHub (Jun 24, 2023).

dify docker compose.yaml配置:
version: '3.1'
services:
#API service
api:
image: langgenius/dify-api:0.3.5
restart: always
environment:
# Startup mode, 'api' starts the API server.
MODE: api
# The log level for the application. Supported values are DEBUG, INFO, WARNING, ERROR, CRITICAL
LOG_LEVEL: DEBUG
# A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using openssl rand -base64 42.
SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
# The base URL of console application, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_URL: ''
# The URL for Service API endpoints,refers to the base URL of the current API service if api domain is
# different from console domain.
# example: http://api.dify.ai
API_URL: ''
# The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_URL: ''
# When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed.
MIGRATION_ENABLED: 'true'
# The configurations of postgres database connection.
# It is consistent with the configuration in the 'db' service below.
DB_USERNAME: postgres
DB_PASSWORD: difyai123456
DB_HOST: db
DB_PORT: 5432
DB_DATABASE: dify
# Specifies the allowed origins for cross-origin requests to the Web API, e.g. https://dify.app or * for all origins.
WEB_API_CORS_ALLOW_ORIGINS: 'http://localhost:3000'
# Specifies the allowed origins for cross-origin requests to the console API, e.g. https://cloud.dify.ai or * for all origins.
CONSOLE_CORS_ALLOW_ORIGINS: 'http://localhost:3000'
# CSRF Cookie settings
# Controls whether a cookie is sent with cross-site requests,
# providing some protection against cross-site request forgery attacks
#
# Default: SameSite=Lax, Secure=false, HttpOnly=true
# This default configuration supports same-origin requests using either HTTP or HTTPS,
# but does not support cross-origin requests. It is suitable for local debugging purposes.
#
# If you want to enable cross-origin support,
# you must use the HTTPS protocol and set the configuration to SameSite=None, Secure=true, HttpOnly=true.
#
# For production purposes, please set SameSite=Lax, Secure=true, HttpOnly=true.
COOKIE_HTTPONLY: 'true'
COOKIE_SAMESITE: 'None'
COOKIE_SECURE: 'true'
# The type of storage to use for storing user files. Supported values are local and s3, Default: local
STORAGE_TYPE: local

dify docker compose ps如下:
image

webapp-conversation配置:
export const APP_ID = 'XXX'
export const API_KEY = 'app-XXX'
export const API_URL = 'http://XX.XX.250.XXX:3009/api'

APP_ID获取方式:
image
API_KEY获取方式:
image

请求报错
image

cookies:
image

Originally created by @xiaoxuan220 on GitHub (Jun 24, 2023). **dify docker compose.yaml配置:** version: '3.1' services: #API service api: image: langgenius/dify-api:0.3.5 restart: always environment: # Startup mode, 'api' starts the API server. MODE: api # The log level for the application. Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` LOG_LEVEL: DEBUG # A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using `openssl rand -base64 42`. SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U # The base URL of console application, refers to the Console base URL of WEB service if console domain is # different from api or web app domain. # example: http://cloud.dify.ai CONSOLE_URL: '' # The URL for Service API endpoints,refers to the base URL of the current API service if api domain is # different from console domain. # example: http://api.dify.ai API_URL: '' # The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from # console or api domain. # example: http://udify.app APP_URL: '' # When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed. MIGRATION_ENABLED: 'true' # The configurations of postgres database connection. # It is consistent with the configuration in the 'db' service below. DB_USERNAME: postgres DB_PASSWORD: difyai123456 DB_HOST: db DB_PORT: 5432 DB_DATABASE: dify # Specifies the allowed origins for cross-origin requests to the Web API, e.g. https://dify.app or * for all origins. WEB_API_CORS_ALLOW_ORIGINS: 'http://localhost:3000' # Specifies the allowed origins for cross-origin requests to the console API, e.g. https://cloud.dify.ai or * for all origins. CONSOLE_CORS_ALLOW_ORIGINS: 'http://localhost:3000' # CSRF Cookie settings # Controls whether a cookie is sent with cross-site requests, # providing some protection against cross-site request forgery attacks # # Default: `SameSite=Lax, Secure=false, HttpOnly=true` # This default configuration supports same-origin requests using either HTTP or HTTPS, # but does not support cross-origin requests. It is suitable for local debugging purposes. # # If you want to enable cross-origin support, # you must use the HTTPS protocol and set the configuration to `SameSite=None, Secure=true, HttpOnly=true`. # # For **production** purposes, please set `SameSite=Lax, Secure=true, HttpOnly=true`. COOKIE_HTTPONLY: 'true' COOKIE_SAMESITE: 'None' COOKIE_SECURE: 'true' # The type of storage to use for storing user files. Supported values are `local` and `s3`, Default: `local` STORAGE_TYPE: local **dify docker compose ps如下:** ![image](https://github.com/langgenius/dify/assets/22339743/d6db228c-d6dc-487c-b3f2-cb9061c7e279) **webapp-conversation配置:** export const APP_ID = 'XXX' export const API_KEY = 'app-XXX' export const API_URL = 'http://XX.XX.250.XXX:3009/api' APP_ID获取方式: ![image](https://github.com/langgenius/dify/assets/22339743/93f6cf69-4ffd-4751-8569-93399eb2f63d) API_KEY获取方式: ![image](https://github.com/langgenius/dify/assets/22339743/5a4f052c-7908-497c-a4e6-25a53dd2c55d) **请求报错** ![image](https://github.com/langgenius/dify/assets/22339743/78ea71f6-f07e-4cff-87c2-63c775b8da65) cookies: ![image](https://github.com/langgenius/dify/assets/22339743/c9aef22e-6208-4b54-9473-1d01073d359b)
yindo closed this issue 2026-02-21 17:26:22 -05:00
Author
Owner

@crazywoola commented on GitHub (Jun 24, 2023):

Do you mean you are using this repo?
Also can you try to curl your customized domain, eg the /parameters with your app secret to see if it succeed.

@crazywoola commented on GitHub (Jun 24, 2023): Do you mean you are using this [repo](https://github.com/langgenius/webapp-conversation)? Also can you try to curl your customized domain, eg the `/parameters` with your app secret to see if it succeed.
Author
Owner

@xiaoxuan220 commented on GitHub (Jun 25, 2023):

Q: Do you mean you are using this repo?
A: Yes

Q: Also can you try to curl your customized domain, eg the /parameters with your app secret to see if it succeed.
A:
image

@xiaoxuan220 commented on GitHub (Jun 25, 2023): Q: Do you mean you are using this [repo](https://github.com/langgenius/webapp-conversation)? A: Yes Q: Also can you try to curl your customized domain, eg the /parameters with your app secret to see if it succeed. A: ![image](https://github.com/langgenius/dify/assets/22339743/d00a7981-2340-4b78-b4c2-a7f8bb80781b)
Author
Owner

@crazywoola commented on GitHub (Jun 25, 2023):

Q: Do you mean you are using this repo? A: Yes

Q: Also can you try to curl your customized domain, eg the /parameters with your app secret to see if it succeed. A: image

I see, you should set Bearer token in headers instead of url parameters
curl -H "Authorization: Bearer {token}"
using -H or --header and if you are using postman, there is a tab called Authorization you can choose bearer token there.

@crazywoola commented on GitHub (Jun 25, 2023): > Q: Do you mean you are using this [repo](https://github.com/langgenius/webapp-conversation)? A: Yes > > Q: Also can you try to curl your customized domain, eg the /parameters with your app secret to see if it succeed. A: ![image](https://user-images.githubusercontent.com/22339743/248553370-fd5f08e0-11db-4517-8dc7-651144388b20.png) I see, you should set Bearer token in headers instead of url parameters `curl -H "Authorization: Bearer {token}"` using -H or --header and if you are using postman, there is a tab called Authorization you can choose bearer token there.
Author
Owner

@xiaoxuan220 commented on GitHub (Jun 26, 2023):

image
image

@xiaoxuan220 commented on GitHub (Jun 26, 2023): ![image](https://github.com/langgenius/dify/assets/22339743/71562140-e732-4609-b574-2b341710a4f2) ![image](https://github.com/langgenius/dify/assets/22339743/c10e8364-6624-4f09-84c5-8af40def106f)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#204