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

[Bug]: Access to XMLHttpRequest has been blocked by CORS policy #4063

Closed
Zhengy1995 opened this issue Nov 26, 2024 · 2 comments
Closed

[Bug]: Access to XMLHttpRequest has been blocked by CORS policy #4063

Zhengy1995 opened this issue Nov 26, 2024 · 2 comments
Labels
bug Something isn't working need reproduction

Comments

@Zhengy1995
Copy link

Zhengy1995 commented Nov 26, 2024

Version

System:
    OS: Linux 5.10 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700
    Memory: 7.75 GB / 23.48 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  npmPackages:
    @rsbuild/core: ^1.1.4 => 1.1.5 
    @rsbuild/plugin-sass: ^1.1.1 => 1.1.1 
    @rsbuild/plugin-vue: ^1.0.5 => 1.0.5

Details

我本地开发环境项目启动在3000端口,从3200端口请求当前项目的接口时,响应头返回的access-control-allow-origin值会多一个,变成
*, http://localhost:3000 而导致跨域问题,实际应该只需要返回*

开发服务器的配置如下:

server: {
    port,
    headers: {
      'Access-Control-Allow-Origin': '*',
    },
    proxy: {
      [VUE_APP_BASE_API ?? '']: {
        target: VUE_APP_TARGET_URL,
        changeOrigin: true,
        pathRewrite: {
          [`^${VUE_APP_BASE_API}`]: VUE_APP_TARGET_BASE_API,
        },
      },
    },
  },

尝试过将headers的配置去掉,结果一样

@Zhengy1995 Zhengy1995 added the bug Something isn't working label Nov 26, 2024
Copy link
Contributor

Hello @Zhengy1995. Please provide a reproduction repository or online demo. For background, see Why reproductions are required. Thanks ❤️

Copy link
Contributor

github-actions bot commented Dec 2, 2024

As the issue was labelled with need reproduction, but no response in 5 days. This issue will be closed. Feel free to comment and reopen it if you have any further questions. For background, see Why reproductions are required.

由于该 issue 被标记为 "需要重现",但在 5 天内没有回应,因此该 issue 将被关闭。如果你有任何进一步的问题,请随时发表评论并重新打开该 issue。背景请参考 为什么需要最小重现

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need reproduction
Projects
None yet
Development

No branches or pull requests

2 participants