当前位置:网站首页>js无法获取headers中Content-Disposition
js无法获取headers中Content-Disposition
2022-07-25 07:09:00 【小莉爱编程】
问题重现
这里是实现了 导出的功能 但是在线上的时候 出现了 导出失败的问题;
我们需要拿到响应头里的Content-Disposition字段的值,从中分离出文件名。

本地可以看到 打印出来了content-disposition

线上的network中也可以看到 这个文件名;但是我把它从请求头中打印出来的时候,就没有这个字段;所以线上就会导出失败
分析问题
浏览器限制了这一类请求头的暴露问题;所以需要服务端配合完成;

解决方案
后端虽然加了这个;但是我们只能在network中看到,无法通过js在请求头中拿到Content-Disposition
所以还需要加一段代码
response.setHeader("Access-Control-Expose-Headers","Content-Disposition");
效果
加上这一段代码就可以导出成功了;
这里附上后端代码

边栏推荐
- 【SemiDrive源码分析】【驱动BringUp】38 - NorFlash & eMMC分区配置
- Dart final and const variables
- Microorganisms are healthy. Don't exclude microorganisms in the human body
- 不只是日志收集,项目监控工具Sentry的安装、配置、使用
- Create a new STM32 project and configure it - based on registers
- Can communication test based on STM32: turn the globe
- Precautions for starting up the server of Dahua Westward Journey
- The relationship between Informatics, mathematics and Mathematical Olympiad (July 19, 2022) C
- 各位老板 问一下 就是我们mysql cdc保存的是配置数据 然后kafka里面堆积的有历史
- 【刷题笔记】搜索旋转排序数组
猜你喜欢

LeetCode46全排列(回溯入门)
![[yolov5 practice 3] traffic sign recognition system based on yolov5 - model training](/img/2f/1d2938dafa17c602c9aaf640be9bf1.png)
[yolov5 practice 3] traffic sign recognition system based on yolov5 - model training

Recycleview realizes horizontal sliding of overlapping items

如何在KVM环境中使用网络安装部署多台虚拟服务器

不只是日志收集,项目监控工具Sentry的安装、配置、使用

With apple not making money, the 2trillion "fruit chain" abandons "fruit" and embraces "special"

Price reduction, game, bitterness, etc., vc/pe rushed to queue up and quit in 2022

How to learn C language?

Rongyun launched a real-time community solution and launched "advanced players" for vertical interest social networking

Special analysis of data security construction in banking industry
随机推荐
In container multicast
【每日一题】剑指 Offer II 115. 重建序列
Wechat applet switchtab transmit parameters and receive parameters
Not only log collection, but also the installation, configuration and use of project monitoring tool sentry
【愚公系列】2022年7月 Go教学课程 016-运算符之逻辑运算符和其他运算符
Example demonstration of math.random() random function
Health clock in daily reminder tired? Then let automation help you -- hiflow, application connection automation assistant
流量对于元宇宙来讲并不是最重要的,能否真正给传统的生活方式和生产方式带来改变,才是最重要的
机器学习两周学习成果
GIS实战应用案例100篇(十七)-基于DEM制作三维地图
"Wei Lai Cup" 2022 Niuke summer multi school training camp 1 supplementary problem solution (incomplete)
Software engineering in Code: regular expression ten step clearance
Decrypting numpy is a key difficulty in solving the gradient
Kubernates-1.24.2 (latest version) + containerd + nexus
CTF Crypto---RSA KCS1_ Oaep mode
MySQL remote login
Box horse "waist cut", blame Hou Yi for talking too much?
Go basic notes_ 5_ Process statement
Leetcode46 Full Permutation (Introduction to backtracking)
Tab bar toggle style