d-lowl / chrome-extension-svelte-boilerplate

MIT License
116 stars 18 forks source link

sockJS being called without port #10

Open michaeljelly opened 4 years ago

michaeljelly commented 4 years ago

Hey! I have found a bug. My console gets totally filled with Errors from attempts to connect to sockjs via the URL http://localhost/sockjs-node/info?t=1593696074915

image

I've tried a lot of ways to get webpack to be able to set the Port such that sockjs can go via the port I'm using, which is 8000.

devServer: { public: 'localhost:' + env.PORT, public: 'localhost:' + env.PORT, sockHost: 'localhost:' + env.PORT, sockPath: ':' + env.PORT, port: env.PORT, sockPort: env.PORT, proxy: { '/sockjs-node/': 'http://localhost:' + env.PORT } },

From navigating to the correct URL manually, it looks to me like if it could just connect via the port, the issue would be solved.

image

This is my first experience diving somewhat deep into webpack, and there's a whole load of similar-ish issues, but I haven't seen anybody get the "no port in URL" problem resolved just yet. Was hoping you might be able to help :) Extensions seems to still work perfectly well without it, but having all that red in the console stresses me out!

Thanks for making the plugin btw, it's a great help to skip straight to coding in Svelte :)

adamwhitlock1 commented 3 years ago

I came across this issue as well. Here is what I did to resolve the issue.

in utils/webserver.js

added some extra config to the server var:

var server = new WebpackDevServer(compiler, {
  hot: true,
  contentBase: path.join(__dirname, '../build'),
  headers: { 'Access-Control-Allow-Origin': '*' },
  public: `localhost:${env.PORT}`,
  disableHostCheck: true,
});

This got rid of all errors in the console for me but your mileage may vary.