Skip to content

Commit

Permalink
Add probable fix for recent versions of Expo Native Client
Browse files Browse the repository at this point in the history
Ref: #326
  • Loading branch information
larixer committed Sep 4, 2017
1 parent bbcd52a commit 4a6e7e0
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tools/webpack.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ function startWebpackDevServer(config, dll, platform, reporter, logger) {
});
}

app.use(webpackDevMiddleware(compiler, _.merge({}, config.devServer, {
const devMiddleware = webpackDevMiddleware(compiler, _.merge({}, config.devServer, {
reporter({ state, stats }) {
if (state) {
logger("bundle is now VALID.");
Expand All @@ -453,7 +453,21 @@ function startWebpackDevServer(config, dll, platform, reporter, logger) {
}
reporter(null, stats);
}
})))
}));
app.use(function(req, res, next) {
if (platform !== 'web') {
// Workaround for Expo Client bug in parsing Content-Type header with charset
const origSetHeader = res.setHeader;
res.setHeader = function (key, value) {
let val = value;
if (key === 'Content-Type') {
val = value.split(';')[0];
}
origSetHeader.call(res, key, val);
};
}
return devMiddleware(req, res, next);
})
.use(webpackHotMiddleware(compiler, { log: false }));

if (config.devServer.proxy) {
Expand Down Expand Up @@ -657,7 +671,7 @@ async function startExpoProdServer() {
app
.use(function(req, res, next) {
req.path = req.url.split('?')[0];
console.log("req:", req.url);
// console.log("req:", req.url);
next();
})
.use(compression())
Expand Down

0 comments on commit 4a6e7e0

Please sign in to comment.