2016-07-24 61 views
1

我已經部署了基於react-js的web應用程序來製作環境,並且從瀏覽器控制檯,我可以看到有一些依賴代碼卡在無限循環中,試圖加載一些通過xhr從本地主機獲取socketjs-node資源。下面是我從瀏覽器控制檯得到的消息:React webapp繼續在PROD中加載本地主機資源env

abstract-xhr.js:132 Mixed Content: The page at '[MY_WEBSITE_ADDRESS]' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:3000/sockjs-node/info?t=1469401504944'. This request has been blocked; the content must be served over HTTPS.o._start @ abstract-xhr.js:132(anonymous function) @ abstract-xhr.js:21 
abstract-xhr.js:132 XMLHttpRequest cannot load http://localhost:3000/sockjs-node/info?t=1469401504944. Failed to start loading.o._start @ abstract-xhr.js:132(anonymous function) @ abstract-xhr.js:21 
client:70 [WDS] Disconnected!l.onclose @ client:70n.dispatchEvent @ eventtarget.js:51(anonymous function) @ main.js:356 

我想知道如果我建設我的js包時沒有任何督促設置。我使用的WebPack和這裏的編制督促包JS設置:

var path = require('path'); 
var webpack = require('webpack'); 

module.exports = { 
    devtool: 'source-map', 
    entry: [ 
    'webpack-dev-server/client?http://localhost:3000', 
    'webpack/hot/only-dev-server', 
    './src/index', 
    'whatwg-fetch' 
    ], 
    output: { 
    path: path.join(__dirname, 'public'), 
    filename: 'bundle.js', 
    publicPath: '/public/' 
    }, 
    plugins: [ 
    new webpack.HotModuleReplacementPlugin(), 
    new webpack.optimize.DedupePlugin(), 
    new webpack.optimize.UglifyJsPlugin({ 
     minimize: true, 
     compress: { 
     warnings: false 
     } 
    }), 
    new webpack.DefinePlugin({ 
     'process.env': { 
     'NODE_ENV': JSON.stringify('production') 
     } 
    }) 
    ], 
    module: { 
    loaders: [{ 
     test: /\.js$/, 
     loaders: ['react-hot', 'babel'], 
     include: path.join(__dirname, 'src') 
    }] 
    } 
}; 

,並在這裏被依賴我使用:

"devDependencies": { 
    "babel-core": "^6.0.20", 
    "babel-eslint": "^4.1.3", 
    "babel-loader": "^6.0.1", 
    "babel-preset-es2015": "^6.0.15", 
    "babel-preset-react": "^6.0.15", 
    "babel-preset-stage-0": "^6.0.15", 
    "eslint": "^1.10.3", 
    "eslint-plugin-react": "^3.6.2", 
    "react-hot-loader": "^1.3.0", 
    "webpack": "^1.12.2", 
    "webpack-dev-server": "^1.12.1" 
    }, 
    "dependencies": { 
    "async": "^1.5.2", 
    "express": "^4.13.4", 
    "mixpanel": "^0.4.0", 
    "mixpanel-browser": "^2.8.1", 
    "radium": "^0.17.1", 
    "react": "^0.14.6", 
    "react-autosuggest": "^3.8.0", 
    "react-bootstrap": "^0.29.4", 
    "react-cookie": "^0.4.7", 
    "react-dom": "^0.14.6", 
    "react-ga": "^2.1.0", 
    "react-geosuggest": "^1.23.0", 
    "react-router": "^2.4.1", 
    "whatwg-fetch": "^1.0.0" 
    } 

我沒有看到abstract-xhr.js是檢查任何明確的標誌啓動時這個查詢。請分享一些想法。謝謝!

+0

我想如果是因爲這一行'的的WebPack設置Entry'屬性:' '?的WebPack-dev的服務器/客戶端的http://本地主機:3000','。現在試着... –

+0

OK結果是這是問題。現在結束這個問題。 –

回答

2

我通過從webpack config中的Entry屬性中刪除此行來解決此問題。

'webpack-dev-server/client?http://localhost:3000',

相關問題