TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at proxyMiddleware (/Users/guanwei/code/company/cbj_pro/cbj_app/node_modules/.pnpm/registry.npmmirror.com+vite@2.7.10_less@4.1.2/node_modules/vite/dist/node/chunks/dep-76613303.js:50062:12)
at Object.preview (/Users/guanwei/code/company/cbj_pro/cbj_app/node_modules/.pnpm/registry.npmmirror.com+vite@2.7.10_less@4.1.2/node_modules/vite/dist/node/chunks/dep-76613303.js:73391:17)
function proxyMiddleware(httpServer, config) {
const options = config.server.proxy;
// lazy require only when proxy is used
const proxies = {};
Object.keys(options) ......
}
Judge is config.preview.proxy, but read is config.server.proxy
[X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
[X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
Describe the bug
script:
$ vite preview --config ./vite.config.preview.ts
config file port
Problem location
https://github.com/vitejs/vite/blob/870e1c076272960a5f390b2cfdd3ae275b3891a5/packages/vite/src/node/preview.ts#L81-L83 Local dependency code
https://github.com/vitejs/vite/blob/870e1c076272960a5f390b2cfdd3ae275b3891a5/packages/vite/src/node/server/middlewares/proxy.ts#L31-L40 Local dependency code
Judge is
config.preview.proxy
, but read isconfig.server.proxy
Reproduction
-
System Info
Used Package Manager
pnpm
Logs
Validations