Configure webpack to allow proxied GitHub Codespaces connections
By default, webpack's development websocket rejects all incoming connections having an unexpected `Host` or `Origin` header: https://webpack.js.org/configuration/dev-server/#devserverallowedhosts This configuration sets `devServer.allowedHosts` to `[".preview.app.github.dev"]` if a GitHub Codespaces environment is detected. Additionally, to handle how GitHub Codespaces forwards ports, webpack's configuration is changed to obtain the full websocket URL from the client script, instead of only the hostname: https://webpack.js.org/configuration/dev-server/#websocketurl
This commit is contained in:
parent
48790db447
commit
1413052d82
1 changed files with 5 additions and 0 deletions
|
@ -2,6 +2,7 @@ const path = require('path');
|
||||||
const common = require('./webpack.common');
|
const common = require('./webpack.common');
|
||||||
const { merge } = require('webpack-merge');
|
const { merge } = require('webpack-merge');
|
||||||
|
|
||||||
|
|
||||||
module.exports = merge(common, {
|
module.exports = merge(common, {
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
output: {
|
output: {
|
||||||
|
@ -11,6 +12,10 @@ module.exports = merge(common, {
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
historyApiFallback: true,
|
historyApiFallback: true,
|
||||||
|
client: {
|
||||||
|
webSocketURL: "auto://0.0.0.0:0/ws"
|
||||||
|
},
|
||||||
|
allowedHosts: process.env.CODESPACES ? [".preview.app.github.dev"] : "auto"
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
|
Loading…
Reference in a new issue