default webpack proxy blocks file downloads
See original GitHub issueproblem
- when using the
proxy
field in package.json, e.g."proxy": "http://localhost:9090"
,<a href='...' download>download</a>
's will fail because:
The development server will only attempt to send requests without text/html in its Accept header to the proxy.
…which the browser adds when using a:href:download nodes. this means that users cannot interact with HTML5 file downloads when using a simple proxy configuration.
discussion
- i would suggest that the behavior attempt to access the proxy iff the
pathname !== pathname(homepage || '/')
- on
4xx
, send the root index HTML, per current behavior
- on
im just thinking out loud here. would love critique/inputs.
i did (after writing this) try the "configure it on your own " method:
"proxy": {
"/api": {
"target": "http://localhost:9090",
"ws": true
},
"/graphql": {
"target": "http://localhost:9090",
"ws": true
}
}
and it all worked 🍑y.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Asset Modules - webpack
By default, data URI emitted by webpack represents file contents encoded by using Base64 algorithm. If you want to use a custom encoding...
Read more >Default proxy setting for create-react-app doesn't handle file ...
json . I have some api calls that are supposed to return .xls file downloads. But can't seem to be get it through...
Read more >Why you should use a proxy server with Create React App
There are two common approaches of setting up proxy servers in React applications developed using CRA. We have the default CRA proxy option ......
Read more >Webpack and Dynamic Imports: Doing it Right - Medium
The problem is if you want to dynamically load a file, in this case, an image, Webpack by default generate a chunk for...
Read more >How to Solve the Chunk Load Error in JavaScript - Rollbar
A possible reason for this is that you have antivirus, browser extensions, proxies, or ad blocking software that may be modifying the file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
go away stale bot! this is one we should definitely consider!
It’d be hard to get this right without breaking most existing users use case. The advanced proxy is probably the best route.