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

Proxy bypass not working in 1.15.0 #560

Closed
cletusw opened this issue Aug 22, 2016 · 11 comments
Closed

Proxy bypass not working in 1.15.0 #560

cletusw opened this issue Aug 22, 2016 · 11 comments

Comments

@cletusw
Copy link

cletusw commented Aug 22, 2016

A webpack.config.js like this (mostly pulled from the docs)

var path = require("path");
module.exports = {
  entry: {
    app: ["./app/main.js"]
  },
  output: {
    path: path.resolve(__dirname, "build"),
    publicPath: "/assets/",
    filename: "bundle.js"
  },
  devServer: {
    proxy: {
      '/': {
        bypass: function(){
          return '/test.html';
        }
      }
    }
  }
};

works fine with webpack-dev-server@1.14.1, but after updating to 1.15.0, I get

$ node_modules/.bin/webpack-dev-server --content-base build/
/Users/claytonwatts/dev/test/node_modules/webpack-dev-server/node_modules/http-proxy-middleware/lib/config-factory.js:42
        throw new Error('[HPM] Missing "target" option. Example: {target: "http://www.example.org"}');
        ^

Error: [HPM] Missing "target" option. Example: {target: "http://www.example.org"}
    at Object.createConfig (/Users/claytonwatts/dev/test/node_modules/webpack-dev-server/node_modules/http-proxy-middleware/lib/config-factory.js:42:15)
    at new HttpProxyMiddleware (/Users/claytonwatts/dev/test/node_modules/webpack-dev-server/node_modules/http-proxy-middleware/lib/index.js:16:45)
    at module.exports (/Users/claytonwatts/dev/test/node_modules/webpack-dev-server/node_modules/http-proxy-middleware/index.js:4:12)
    at /Users/claytonwatts/dev/test/node_modules/webpack-dev-server/lib/Server.js:184:9
    at Array.forEach (native)
    at Object.Server.features.proxy (/Users/claytonwatts/dev/test/node_modules/webpack-dev-server/lib/Server.js:171:19)
    at Server.<anonymous> (/Users/claytonwatts/dev/test/node_modules/webpack-dev-server/lib/Server.js:274:20)
    at Array.forEach (native)
    at new Server (/Users/claytonwatts/dev/test/node_modules/webpack-dev-server/lib/Server.js:273:40)
    at Object.<anonymous> (/Users/claytonwatts/dev/test/node_modules/webpack-dev-server/bin/webpack-dev-server.js:183:1)

Looks like this is the commit that adds http-proxy-middleware.

@SpaceK33z
Copy link
Member

Confirmed this is also happening with 2.1.0-beta.0.

@SpaceK33z
Copy link
Member

Could you try out if #563 works for you?

@cletusw
Copy link
Author

cletusw commented Aug 23, 2016

@SpaceK33z I'm now getting Fatal error: ENOENT: no such file or directory, open '<project>/node_modules/webpack-dev-server/client/live.bundle.js'

Not sure if that's from this or if I'm missing something else. I'll look a little deeper.

@SpaceK33z
Copy link
Member

@cletusw, you need to run npm i && npm run prepublish in node_modules/webpack-dev-server. You could also copy/paste the contents of lib/Server.js in my PR (hacky hacky ;p).

@cletusw
Copy link
Author

cletusw commented Aug 23, 2016

@SpaceK33z That did it! Working fine now, thanks!

@SpaceK33z
Copy link
Member

@cletusw, awesome! There are a few other small bugs in 1.15.0 that I want to fix first, but a release should happen soon.

@seansfkelley
Copy link

Would it be possible to make a release now, just for this, since it's a P0? A lot of my team members keep hitting this issue and wasting time debugging until they find this ticket.

@txangel
Copy link

txangel commented Aug 31, 2016

@SpaceK33z we had to fix out version to 1.14.1 (instead of ^1.14.1) for now, which is not a very good practice.
Do you think it would be possible to get a release sometime this week?

On top of that you might want to increase the test coverage here to reduce the risk of having another breaking change when upgrading the minor version.
Plenty of teams depend on your code mate; the price of fame (:

@SpaceK33z
Copy link
Member

@txangel, I'm trying, but it is out of my hands (I have no permissions to publish to npm).

You're right in that there should be test coverage. It is very hard to test the dev-server thoroughly though, but there are some things we could test in isolation.

@SpaceK33z
Copy link
Member

This has been released as part of 1.15.1.

@seansfkelley
Copy link

Thank you!

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

No branches or pull requests

4 participants