We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Vben Admin V5
Access to XMLHttpRequest at 'http://localhost:48090/admin-api/system/dict-type/page?pageNo=1&pageSize=20&createTime[]=2025-03-11+00:00:00&createTime[]=2025-03-13+00:00:00' from origin 'http://localhost:5666' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. RequestClient能不能集成 qs 来解决这个问题
pnpm add qs pnpm add -D @types/qs import qs from 'qs' export const requestClient = createRequestClient(apiURL, { responseReturn: 'data', // axios get请求 params 带数组参数的处理 // from origin 'url' has been blocked by CORS policy paramsSerializer(params) { // 'repeat' | 'comma' | 'brackets' | 'indices' return qs.stringify(params, { arrayFormat: 'repeat' }) }, }) // 最好是集成到 RequestClient 类的参数里 export const requestClient = createRequestClient(apiURL, { responseReturn: 'data', // 给 RequestClient 一个参数,免得用户还得安装 qs 包 paramsSerializer: 'comma', // 'repeat' | 'comma' | 'brackets' | 'indices' })
null
all
The text was updated successfully, but these errors were encountered:
你这个报错是跨域导致的
Sorry, something went wrong.
应该不是跨域问题,如果是跨域问题,那么无论传什么参数都会报跨域的错误
然而只有含有数组参数 如: page?createTime[]=2025-03-01&createTime[]=2025-03-02 会报错
page?createTime[1]=2025-03-01&createTime[2]=2025-03-02 不会报错 page?createTime=2025-03-01&createTime=2025-03-02 不会报错
https://www.cnblogs.com/nayek/p/12284036.html 解决方案参考这个
No branches or pull requests
Version
Vben Admin V5
Describe the bug?
Access to XMLHttpRequest at 'http://localhost:48090/admin-api/system/dict-type/page?pageNo=1&pageSize=20&createTime[]=2025-03-11+00:00:00&createTime[]=2025-03-13+00:00:00' from origin 'http://localhost:5666' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
RequestClient能不能集成 qs 来解决这个问题
Reproduction
null
System Info
Relevant log output
Validations
The text was updated successfully, but these errors were encountered: