incubator-answer icon indicating copy to clipboard operation
incubator-answer copied to clipboard

fix: if PUBLIC_URL setted, static resources cannot be fetched from the backend.

Open liuyuanzhi-cn opened this issue 1 year ago • 0 comments

Bug Reproduction Steps

  1. Modify the PUBLIC_URL in the ui/.env.production file:
  TSC_COMPILE_ON_ERROR=true
  ESLINT_NO_DEV_ERRORS=true
  PUBLIC_URL = /forum
  REACT_APP_API_URL = /
  1. Recompile
  make ui
  make build
  1. Execute the initialization command:
INSTALL_PORT=9080 ./answer init -C ./answer-data/
  1. Access the initialization configuration page at http://localhost:9080/install and encounter the following error.

answer error page

Bug Resolution

During initialization and runtime, it is necessary to add the environment variable PUBLIC_URL.

# Initialization
INSTALL_PORT=9080 PUBLIC_URL=/forum ./answer init -C ./answer-data/
# Run
PUBLIC_URL=/forum ./answer run -C ./answer-data/

Note:

  1. If the value of PUBLIC_URL is the default /, there is no need to set the environment variable.
  2. The value of PUBLIC_URL must not end with /. For example, PUBLIC_URL=/forum is correct, while PUBLIC_URL=/forum/ is incorrect.

liuyuanzhi-cn avatar Feb 23 '24 10:02 liuyuanzhi-cn