question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack dev server proxy failing

See original GitHub issue

Describe the bug

I am using storybook in full control mode and attempting to add a proxy to the webpack dev server for certain requests (as the backend API I’m querying is served off a different localhost port). This is failing to work.

To Reproduce

  1. Setup storybook in full control mode
  2. Mutate config with a devServer.proxy

Code snippets

// Note: storybook is served on PORT 9001
module.exports = async ({ config, mode }) => {
    config.devServer = {
      proxy: [
        {
          context: ["/requests"],
          target: "http://localhost"
        }
      ]
    };

    return config;
};

System:

  • MacOS
  • Framework: react
  • Version: 5.0.10

Apologies if this is a duplicate, however https://github.com/storybooks/storybook/issues/208 and the other issues I found didn’t seem to address this.

Any help would be much appreciated! 🙂

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
ndelangencommented, Jun 3, 2019

@majames You can use the middleware.js feature storybook has: https://github.com/storybookjs/storybook/pull/435#issuecomment-366701274

The feature still needs documentation. We could use your help with that.

We don’t use webpack-dev-server directly. We use the devMiddleware: https://github.com/webpack/webpack-dev-middleware

which doesn’t support proxies

0reactions
majamescommented, Jun 4, 2019

Thanks for following up @shilman and @ndelangen! I’ll check it out and see whether it solves the problem for my use case! 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

devServer proxy not working · Issue #793 · webpack ... - GitHub
devServer proxy doesn't proxy. If the current behavior is a bug, please provide the steps to reproduce. Client server running at localhost:8080 ...
Read more >
vue.js - webpack dev-server: Avoid proxy errors on HTTP ...
This error message comes from node_modules/@vue/cli-service/lib/util/prepareProxy.js , which define a onError callback for node-http-proxy ;.
Read more >
DevServer - webpack
Allows dev-server to register custom mime types. The object is passed to the underlying webpack-dev-middleware . See documentation for usage notes. webpack.
Read more >
[SOLVED] Proxy stopped working - Help Requests
I updated most packages and proxy stopped working. Any ideas from looking at the below as to what could be the problem? Here,...
Read more >
Development Server - SurviveJS
devServer.proxy - If you are using multiple servers, you have to proxy WDS to them. The proxy setting accepts an object of proxy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found