如何配置 React 应用程序以在 spring 引导后端中的本地主机 8080 中启动
How configure react app to start in localhost 8080 in spring boot backend
这是我的 package.json 反应。
{
"name": "reactjs",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"bootstrap": "^4.5.3",
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:8080",
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
我在 package.json 文件中使用了代理,但它对我不起作用。添加此代理后,它没有显示任何错误,但也托管在本地 host3000 中。
React 通常是 front-end 框架。这意味着在一天结束时,它将构建成一堆 js 文件。因此 react-scripts build
。您应该将这些文件部署到可以提供静态文件的适当 HTTP 服务器。检查这个以从节点 制作 HTTP 文件服务器。 react-scripts start
仅为 development-purpose 启动 Web 服务器。不要将其用作真正的网络服务器。
这是我的 package.json 反应。
{
"name": "reactjs",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"bootstrap": "^4.5.3",
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:8080",
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
我在 package.json 文件中使用了代理,但它对我不起作用。添加此代理后,它没有显示任何错误,但也托管在本地 host3000 中。
React 通常是 front-end 框架。这意味着在一天结束时,它将构建成一堆 js 文件。因此 react-scripts build
。您应该将这些文件部署到可以提供静态文件的适当 HTTP 服务器。检查这个以从节点 制作 HTTP 文件服务器。 react-scripts start
仅为 development-purpose 启动 Web 服务器。不要将其用作真正的网络服务器。