• home > tools > Bundler > vite >

    vite proxy axios出现TypeError: Cannot read property 'split' of null

    Author:zhoulujun Date:

    今天把之前vue bkui-cli 创建的项目copy 值vite 工程。发现报错: Cannot read properties of null (reading split ) 。devServer proxy target需要提供完整的url,如http: www xxx com, 缺少http,就会报上述错误


    今天把之前vue bkui-cli 创建的项目copy 值vite 工程。发现报错:

     ERROR  10:28:35 AM [vite] Internal server error: Cannot read properties of null (reading 'split') 

    ERROR  10:28:35 AM [vite] Internal server error: Cannot read properties of null (reading 'split')

    at required (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:55482:23)

    at Object.common.setupOutgoing (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:55610:7)

    at Array.stream (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:56621:16)

    at ProxyServer.<anonymous> (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:56934:21)

    at viteProxyMiddleware (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:57190:23)

    at call (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:44106:7)

    at next (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:44050:5)

    at cors (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:44574:7)

    at /Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:44610:17

    at originCallback (/Userszhoulujun/workspace/vite-vue3-tsx/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:44600:15)

    vite proxy 报错

    google 找到了答案,记录一下:https://github.com/PanJiaChen/vue-element-admin/issues/3285#issuecomment-728670320

    我是这解决的,devServer.proxy.target需要提供完整的url,如http://www.xxx.com, 缺少http,就会报上述错误

    这个报错真的打疼,一点提示都没有,安装上面的改了,就好了


    转载本站文章《vite proxy axios出现TypeError: Cannot read property 'split' of null》,
    请注明出处:https://www.zhoulujun.cn/html/tools/Bundler/vite/8840.html