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

No Cors headers present.

Aperta
#37 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
enhancement good first issue help wanted pri-high
Lingua principale
JavaScript
Stelle
51
Fork
14
Merge medio
1g 8h
PR unite (30g)
4

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.