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

请求代理 rewrite 重写地址不生效 #754

Closed
liangxp opened this issue Sep 8, 2024 · 4 comments
Closed

请求代理 rewrite 重写地址不生效 #754

liangxp opened this issue Sep 8, 2024 · 4 comments
Assignees

Comments

@liangxp
Copy link

liangxp commented Sep 8, 2024

tdesign-vue-next-starter 版本

0.10.0

重现链接

No response

重现步骤

vite.config.ts配置代理如下:

server: {
      port: 3002,
      host: '0.0.0.0',
      proxy: {
        [VITE_API_URL_PREFIX]: {
          target:VITE_API_URL,
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ""),
        }
      },
    }

VITE_API_URL_PREFIX这个参数就是环境变量里面的/api,这里想代理的时候去掉/api

期望结果

代理的时候去掉/api

实际结果

请求依然保持了/api

框架版本

"vue": "3.3.13"

浏览器版本

No response

系统版本

No response

Node版本

18

补充说明

No response

Copy link

github-actions bot commented Sep 8, 2024

👋 @liangxp,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

Copy link

github-actions bot commented Sep 8, 2024

♥️ 有劳 @timi137137 @liweijie0812 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @liangxp

@liangxp liangxp changed the title 请求代理 rewrite 重写地址不省心 请求代理 rewrite 重写地址不生效 Sep 8, 2024
@timi137137
Copy link
Collaborator

@liangxp
Copy link
Author

liangxp commented Sep 9, 2024

VITE_IS_REQUEST_PROXY = false

@liangxp liangxp closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants