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.

devServer.proxy do not support array type and error msg is confusing

See original GitHub issue

Version

3.9.0

Environment info

System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
  Binaries:
    Node: 10.15.1 - ~/.nvm/versions/node/v10.15.1/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.1/bin/npm
  Browsers:
    Chrome: 75.0.3770.100
    Firefox: 67.0
    Safari: 12.1.1
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.0.0 
    @vue/babel-preset-app:  3.8.0 
    @vue/babel-preset-jsx:  1.0.0 
    @vue/babel-sugar-functional-vue:  1.0.0 
    @vue/babel-sugar-inject-h:  1.0.0 
    @vue/babel-sugar-v-model:  1.0.0 
    @vue/babel-sugar-v-on:  1.0.0 
    @vue/cli-overlay:  3.8.0 
    @vue/cli-plugin-babel: ^3.8.0 => 3.8.0 
    @vue/cli-plugin-eslint: ^3.8.0 => 3.8.0 
    @vue/cli-service: ^3.8.4 => 3.8.4 
    @vue/cli-shared-utils:  3.8.0 
    @vue/component-compiler-utils:  2.6.0 
    @vue/preload-webpack-plugin:  1.1.0 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^5.2.3 => 5.2.3 (4.7.1)
    vue: ^2.6.10 => 2.6.10 
    vue-eslint-parser:  6.0.4 (2.0.3, 5.0.0)
    vue-hot-reload-api:  2.3.3 
    vue-lazyload:  1.2.3 
    vue-loader:  15.7.0 
    vue-router: ^3.0.6 => 3.0.6 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.10 => 2.6.10 
    vue-template-es2015-compiler:  1.9.1 
    vuex: ^3.1.1 => 3.1.1 
  npmGlobalPackages:
    @vue/cli: 3.9.0

Steps to reproduce

// vue.config.js
module.exports = {
  devServer: {
    proxy: [
      {
        context: ['/v/api', '/v/test'],
        target: https://test.com/,
      },
    ],
  }
}

What is expected?

should work fine

What is actually happening?

vue-cli-service serve returns error and given hint:

When specified, "proxy" in package.json must be a string or an object.
Instead, the type of "proxy" was array.
Either remove "proxy" from package.json, or make it an object.

Actually we didn’t write proxy in package.json, this error message makes us confusing.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:8

github_iconTop GitHub Comments

1reaction
JounQincommented, Oct 21, 2019

My temporary workaround:

const config = {
  target: process.env.PROXY_TARGET || 'http://localhost:8000',
  secure: false,
  changeOrigin: true,
  logLevel: 'error',
}

const PROXY_URLS = ['api', 'media'].map(_ => '/' + _)

module.exports = PROXY_URLS.reduce(
  (proxies, url) =>
    Object.assign(proxies, {
      [url]: config,
    }),
  {},
)
0reactions
mwahlhuettercommented, Feb 15, 2022

This is still a problem in v5.0.0-rc.2 Any news on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to apply createProxyMiddleware in webpack?
AFAIK it's not possible to use custom middleware using Webpack's dev server. If you need the proxy bad enough, you can hook a...
Read more >
Changelog - Cypress Documentation
Fixed a regression introduced in 12.0.0 that sometimes does not allow cy.origin() to communicate correctly with the navigated to domain. Fixes #25010. 12.0.0....
Read more >
Configure a proxy for your API calls with Angular CLI - | juri.dev
Learn how to configure the Angular CLI to proxy API calls to your backend and thus avoid having to deal with CORS headers....
Read more >
webpack-dev-server | Yarn - Package Manager
--no-history-api-fallback Disallows to proxy requests through a specified index page. --host <value> Allows to specify a hostname to use. --hot [value] Enables ...
Read more >
API Proxying for Dev - Quasar Framework
quasar/app-webpack) How to use an API proxy with the Quasar dev server. ... Obviously, these relative paths will probably not work while you...
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