Skip to content

Commit 0925f01

Browse files
authored
fix: add cors headers to local file redirects (#67)
* fix: add cors headers to local file redirects * chore: address review comments
1 parent 7d240fa commit 0925f01

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/proxy-middleware/rule_action_processor/handle_mixed_response.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ const handleMixedResponse = async (ctx, destinationUrl) => {
5252
const mimeType = mime.lookup(path)
5353
const bodyContent = buffers.toString("utf-8") // assuming utf-8 encoding
5454
const headers = mimeType ? {
55-
"Content-Type": mimeType,
55+
"content-type": mimeType,
5656
"Content-Length": Buffer.byteLength(bodyContent),
5757
"Cache-Control": "no-cache"
5858
} : {
5959
"Cache-Control": "no-cache"
6060
}
61+
62+
headers["access-control-allow-origin"] = "*";
63+
headers["access-control-allow-credentials"] = "true";
64+
headers["access-control-allow-methods"] = "*";
65+
headers["access-control-allow-headers"] = "*";
66+
6167
return {
6268
status: true,
6369
response_data: {

0 commit comments

Comments
 (0)