0
Google App Engine新手在這裏。在向Google App Engine部署React應用時出現502服務器錯誤
我已經部署了我的陣營應用谷歌,但是當我嘗試預覽它,我得到一個502錯誤:
Failed to load resource: the server responded with a status of 502()
的app.yaml:
env: flex
runtime: nodejs
的package.json:
{
"name": "react-boilerplate",
"version": "1.0.0",
"description": "Minimal boilerplate for react",
"main": "index.js",
"scripts": {
"start": "node server.js",
"bundle": "./node_modules/.bin/webpack --config webpack.config.js",
"prestart": "npm run bundle"
},
"author": "",
"license": "ISC",
"babel": {
"presets": [
"es2015",
"react",
"stage-2"
]
},
"engines": {
"node": "6.11.0",
"npm": "3.10.10"
},
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"css-loader": "^0.28.0",
"node-sass": "^4.5.2",
"sass-loader": "^6.0.5",
"style-loader": "^0.16.1",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"axios": "^0.16.2",
"d3": "^4.9.1",
"express": "^4.15.3",
"pug": "^2.0.0-rc.2",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-redux": "^5.0.5",
"redux": "^3.7.1",
"redux-thunk": "^2.2.0",
"webpack": "^3.3.0"
}
}
webpack.config.js:
var webpack = require('webpack');
module.exports = {
entry: [
'./src/index.js'
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: [/\.css$/, /\.scss$/],
exclude: /node_modules/,
loaders: ['style-loader', 'css-loader', 'sass-loader']
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
contentBase: './dist',
historyApiFallback: true
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
}
用盡想法。任何幫助都是極好的!
是'server.js'你的webpack HMR服務器嗎?不建議在生產中運行。你不應該需要像GAE這樣的純JS JS瀏覽器端應用程序;你應該看看像[Google Cloud Storage](https://cloud.google.com/storage/docs/hosting-static-website)之類的東西。僅供參考,'502'通常意味着'壞網關',這意味着'無法與您正在尋找的上游服務器進行通信。' –
什麼是HMR,以及如何檢查它是否是我的webpack HMR服務器?對不起有點新穎 – doctopus
沒關係,我想出瞭解決方案。我的答案如下 – doctopus