当前位置:网站首页>JS cannot get content disposition in headers
JS cannot get content disposition in headers
2022-07-25 07:13:00 【Xiao Li loves programming】
Export download function
Problem recurrence
The front end realizes the export and download function
Here is the realization of Export function But when online There is The problem of export failure ;
We need to get the response header Content-Disposition Value of field , Separate the file name .

You can see here It's printed content-disposition

Online network You can also see that This filename ; But when I print it out from the request header , There is no such field ; So online export will fail 
To analyze problems
Browsers limit the exposure of this kind of request headers ; Therefore, it needs the cooperation of the server ;

Solution
Although this is added to the back end ; But we can only network see , Unable to get js Get it in the request header Content-Disposition
So you need to add a piece of code
response.setHeader("Access-Control-Expose-Headers","Content-Disposition");
effect
With this piece of code, you can export successfully ;
The back-end code is attached here

边栏推荐
- 如何学习 C 语言?
- Rust standard library - implement a TCP service, and rust uses sockets
- Will eating fermented steamed bread hurt your body
- vulnhub CyberSploit: 1
- 华为无线设备配置WAPI-证书安全策略
- Dart final and const variables
- [cloud native] the ribbon is no longer used at the bottom of openfeign, which started in 2020.0.x
- Can interface debugging still play like this?
- 10 minutes to understand how JMeter plays with redis database
- __ str__ Output class
猜你喜欢

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

9大最佳工程施工项目管理系统

章鱼网络 Community Call #1|开启 Octopus DAO 构建
![[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!](/img/11/24f92b4362026ec2c01492d195560b.png)
[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!

Basic usage of thread class

代码中的软件工程:正则表达式十步通关

第一启富金怎么样

YOLOv7模型推理和训练自己的数据集

Wechat applet switchtab transmit parameters and receive parameters

Hierarchical reinforcement learning: a comprehensive survey
随机推荐
What are the types of financial products in 2022? Which is suitable for beginners?
30 times performance improvement -- implementation of MyTT index library based on dolphin DB
YOLOv7模型推理和训练自己的数据集
What are runtimecompiler and runtimeonly
华为无线设备STA黑白名单配置命令
Not only log collection, but also the installation, configuration and use of project monitoring tool sentry
Ask the bosses: MySQL CDC stores configuration data, and Kafka has history
150. Evaluation of inverse Polish expression
Openatom xuprechain open source biweekly report | 2022.7.11-2022.7.22
Enable the free pan domain SSL certificate for kubesphere cluster and realize the automatic update and distribution of certificates
代码中的软件工程:正则表达式十步通关
Dart final and const variables
用VS Code搞Qt6:编译源代码与基本配置
CEPH in hand, I have!
Common cross domain scenarios
PADS导出gerber文件
Luo min from qudian, prefabricate "leeks"?
How to learn C language?
微信小程序switchTab传参以及接收参数
Two week learning results of machine learning