Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to configure sockjs url? #1249

Closed
leepowelldev opened this issue Dec 29, 2017 · 6 comments
Closed

Possible to configure sockjs url? #1249

leepowelldev opened this issue Dec 29, 2017 · 6 comments

Comments

@leepowelldev
Copy link

I have a very simple setup of the webpack-dev-server running on port 8080 behind an nginx proxy listening on port 80 and routing traffic to the upstream server. However, I'm getting lots of console log errors when the server tries to access the sock.js instance:

 http://wepackserver.localhost:8080/sockjs-node/info?t=1514563803767

Is is possible to configure the setup of sock.js to go straight to:

http://wepackserver.localhost/sockjs-node/info?t=1514563803767

I've looked at the documentation and tried using the proxy option, but nothing seems to work.

Here is my config, created by the vue-cli package using the webpack-simple template:

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

module.exports = {
  entry: './src/app.js',
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/dist/',
    filename: 'build.js'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'vue-style-loader',
          'css-loader'
        ]
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
          }
          // other vue-loader options go here
        }
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js'
    },
    extensions: ['*', '.js', '.vue', '.json']
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true,
    overlay: true,
    port: 8080,
    host: '0.0.0.0',
    disableHostCheck: true
  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map'
}

if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    })
  ])
}
@leepowelldev
Copy link
Author

Closing - not sure how I missed the 'public' configuration property.

@oscarhco
Copy link

Hey @leepowellcouk !
I am having this issue, can you elaborate on what exactly the 'public' configuration property is?
Thanks in advance.

@sharkySharks
Copy link

same ^

@sharkySharks
Copy link

@oscarhco found it: https://webpack.js.org/configuration/dev-server/#devserverpublic

@douglasg14b
Copy link

The public property works, but sockjs still tries to use the port, which doesn't work if you're proxying and the port is proxied for you...

@mnpenner
Copy link

Any solution to this? I've set sockPort to 8080 but in my browser I keep seeing GET http://localhost:8082/sockjs-node/info?t=1662940719365 net::ERR_CONNECTION_REFUSED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants