小编Vir*_*raj的帖子

为 facebook/create-react-app 生产版本手动设置 PORT 和 HOST

我使用 facebook/create-react-app 创建一个 React 应用程序,并成功在http://localhost:5000上运行生产构建。

我的问题是有什么方法可以更改此生产版本中的 5000 端口吗?

根据高级配置,在生产中无法更改 HOST 和 PORT,只能用于开发

https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration

这是我的 package.json

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "deploy": "serve -s build"
  }
Run Code Online (Sandbox Code Playgroud)

这是我的.env

##
HOST=127.0.0.1
PORT=8008
## PUBLIC_URL=http://myexamplesite.lk/
##

REACT_APP_ROOT_BASE_URL=https://myexamplesite.lk/api/
REACT_APP_ROOT_BASE_URL_META=http://myexamplesite.lk/
Run Code Online (Sandbox Code Playgroud)

reactjs react-scripts create-react-app

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

create-react-app ×1

react-scripts ×1

reactjs ×1