小编Ian*_*ury的帖子

Azure 上的 React + Express:无效的主机标头

错误

部署到支持多容器的 Azure Web 应用程序时,我收到来自https://mysite.azurewebsites.com“无效主机标头”消息

本地设置

这运行良好。

我有两个 Docker 容器:client一个 React 应用程序和server一个托管我的 API 的 Express 应用程序。我正在使用代理将我的 API 托管在server.

client's package.json 我已经定义:

"proxy": "http://localhost:3001"
Run Code Online (Sandbox Code Playgroud)

我使用以下 docker compose 文件在本地构建。

version: '2.1'

services:
  server:
    build: ./server
    expose:
      - ${APP_SERVER_PORT}
    environment:
      API_HOST: ${API_HOST}
      APP_SERVER_PORT: ${APP_SERVER_PORT}
    ports: 
      - ${APP_SERVER_PORT}:${APP_SERVER_PORT}
    volumes: 
      - ./server/src:/app/project-server/src
    command: npm start

  client: 
    build: ./client
    environment: 
      - REACT_APP_PORT=${REACT_APP_PORT}
    expose:
      - ${REACT_APP_PORT}
    ports:
      - ${REACT_APP_PORT}:${REACT_APP_PORT}
    volumes:
      - ./client/src:/app/project-client/src
      - ./client/public:/app/project-client/public
    links: …
Run Code Online (Sandbox Code Playgroud)

azure express docker reactjs

5
推荐指数
1
解决办法
1579
查看次数

标签 统计

azure ×1

docker ×1

express ×1

reactjs ×1