tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.
https://www.naiveui.com
MIT License
15.53k stars 1.63k forks source link

n-upload GET request with headers #6036

Open swuecho opened 2 weeks ago

swuecho commented 2 weeks ago

Clear and concise description of the problem

image

点击这个link 触发下载, 但是headers 没有带上, 导致 unauthorized

Suggested solution

GET request 带上headers

Alternative

No response

Additional context

No response

Validations

swuecho commented 2 weeks ago

或者提供是否显示文件链接的props, 显示了文件链接, 但是又不能用, 比较棘手.

jahnli commented 2 weeks ago

没太理解需求 data with-credentials ?

swuecho commented 2 weeks ago

点击链接的时候会发送get 请求. 后台根据JWT token 鉴权的, with-credentials 根据文档是带上cookies

swuecho commented 2 weeks ago

https://github.com/tusen-ai/naive-ui/blob/6bea68a3a55a832dc6f90d79507cdd096ea8d0e6/src/upload/src/UploadFile.tsx#L261

https://github.com/tusen-ai/naive-ui/blob/6bea68a3a55a832dc6f90d79507cdd096ea8d0e6/src/upload/src/UploadFile.tsx#L179

handlePreviewClick 应该 preventDefault() ? 否则默认的行为会打开链接?

swuecho commented 2 weeks ago

点击链接的时候会发送get 请求. 后台根据JWT token 鉴权的, with-credentials 根据文档是带上cookies

这个猜想有误, 应该是浏览器打开了链接.

jahnli commented 2 weeks ago

可能设计的点击浏览器打开