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

Webpack and devServer Proxy not working as per the example in the Documentation #17908

Open
pafr-zyata opened this issue Mar 18, 2025 · 2 comments

Comments

@pafr-zyata
Copy link

What happened?

I setup a new quasar project using webpack.

I then added to the quasar.config.js the following:

devServer: {
  proxy: {
    // proxy all requests starting with /api to jsonplaceholder
    '/api': {
      target: 'http://some.api.target.com:7070',
      changeOrigin: true,
      pathRewrite: {
        '^/api': ''
      }
    }
  }
}

Then trying to run the app with quasar dev I get compile errors which state that webPack devServer proxy propertie expects the proxy property to be an array.

After looking at the webpack.devServer Documentation I switched the proxy statement to:

devServer: {
  proxy: [
    // proxy all requests starting with /api to jsonplaceholder
    {
      context: ["/api"],
      target: 'http://some.api.target.com:7070',
      changeOrigin: true,
      pathRewrite: {
        '^/api': ''
      }
    }
  ]
}

Then starting the app with quasar dev works, but nothing is beeing proxied.

What did you expect to happen?

I expect at least one of the configs to work, honestly I expect the config from the documentation to work.

Reproduction URL

https://example.com

How to reproduce?

Setup a new quasar project with webpack, add the devServer and proxy settings.

Flavour

Quasar CLI with Webpack (@quasar/cli | @quasar/app-webpack)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)

Platforms/Browsers

No response

Quasar info output

Relevant log output

Additional context

No response

Copy link

Hi @pafr-zyata! 👋

It looks like you provided an invalid or unsupported reproduction URL.
Do not use any service other than Codepen, jsFiddle, StackBlitz, CodeSandbox, and GitHub.
Make sure the URL you provided is correct and reachable. You can test it by visiting it in a private tab, another device, etc.
Please edit your original post above and provide a valid reproduction URL as explained.

Without a proper reproduction, your issue will have to get closed.

Thank you for your collaboration. 👏

@pafr-zyata
Copy link
Author

I found the problem, the proxy only seems to work when you start the dev mode with port 8080. If you do not specifiy the port, then the proxy directive in the devServer does not work, neither with webpack>=4 nor with the current vite.

Sorry for the dumb reproduction url, but I do not have time to slim down a 4 year old project so that I can post it on jsfiddle or any other public service like that. Sorry.

And the steps to reproduce are simple enough that anyone can start a new quasar project and add a proxy in the devServer in quasar.config.js

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

1 participant