activescott / activescott/serverless-aws-static-file-handler

No Cors headers present.

未关闭
#37 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
enhancement good first issue help wanted pri-high
主要语言
JavaScript
星标
51
派生
14
平均合并
1 天 8 小时
30 天内合并 PR
4

描述

### Expected behavior:

Serve static Files with cors enabled. No cors headers present.

### Actual behavior:

Cors error:

`Access to XMLHttpRequest at 'https://[URL]' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.`

### Steps to reproduce the problem:

Serve the static file:

event.path = file;
Return fileHandler.get(event, context);

### Bonus Workaround

Adding the headers it worked but I need to access to the response object.

```
event.path = file;
let response = await fileHandler.get(event, context)
response.headers = {
'Content-Type': response.headers["Content-Type"],
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Origin': '*'
}
return response;
```

### Environment:

OS: Debian 10 Buster

Node Version: 10.15.3

serverless-aws-static-file-handler Version: 2.0.4

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。