Skip to content

in-memory resources are not loaded after proxy bypass #612

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

Closed
skwakman opened this issue Sep 21, 2016 · 2 comments · Fixed by #613
Closed

in-memory resources are not loaded after proxy bypass #612

skwakman opened this issue Sep 21, 2016 · 2 comments · Fixed by #613

Comments

@skwakman
Copy link
Contributor

skwakman commented Sep 21, 2016

When using proxy's bypass function, resources that are bypassed and are part of the in-memory webpack bundle are not retrieved. Instead, only files from the filesystem are retrieved.

Example:
Running the server using --inline

proxy: [{
  context: ['**'],
  target: 'http://someOtherServer:1234/',
  bypass: function(req, res, proxyOptions) {
    if (req.url.indexOf('clientlib-all.js') != -1) {
      return '/bundle.js'; // this file is part of the webpack bundle and should be loaded from memory, but it's not. Instead it returns a 404 _or_ if the file exists on the file system, that one is loaded instead.
    }
    return false;
  }
}];

I've fixed this locally by manually editing webpack-dev-server's Server.js file:

// ... line 269
    var defaultFeatures = ["setup", "headers", "middleware"];
    if(options.proxy)
        defaultFeatures.push("proxy"); // add a second parameter with value "middleware" to this .push call and it works
// ...

webpack: tested with 1.13.2, although bug is in server, not in webpack itself
webpack-dev-server: confirmed on 1.16.1 but might also be present in 2.x
OS: OSX 10.11.6, local installation

skwakman added a commit to skwakman/webpack-dev-server that referenced this issue Sep 21, 2016
added additional `middleware` feature to express' use-chain after proxy to enable proxy-bypass retrievals to in-memory resources. Fixes webpack#612.
@SpaceK33z
Copy link
Member

PR welcome.

@skwakman skwakman mentioned this issue Sep 21, 2016
11 tasks
SpaceK33z pushed a commit that referenced this issue Sep 21, 2016
added additional `middleware` feature to express' use-chain after proxy to enable proxy-bypass retrievals to in-memory resources. Fixes #612.
@skwakman
Copy link
Contributor Author

Can this fix also be merged for the 1.x branch?

skwakman added a commit to skwakman/webpack-dev-server that referenced this issue Sep 21, 2016
@skwakman skwakman mentioned this issue Sep 21, 2016
11 tasks
SpaceK33z pushed a commit that referenced this issue Sep 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants