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

No Cors headers present.

Đang mở
#37 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
enhancement good first issue help wanted pri-high
Ngôn ngữ chính
JavaScript
Star
51
Fork
14
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
4

Mô tả

### 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.