Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Fixes for CORS implementation #170

Merged
merged 2 commits into from
Mar 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/actions/blob/PreflightBlobRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ class PreflightBlobRequest {
const response = new AzuriteResponse(); // Add Access-Control-Expose-Headers
response.addHttpProperty(N.ACCESS_CONTROL_ALLOW_ORIGIN, req.httpProps[N.ORIGIN]); // Refactor into response
response.addHttpProperty(N.ACCESS_CONTROL_ALLOW_METHODS, req.httpProps[N.ACCESS_CONTROL_REQUEST_METHOD]);
response.addHttpProperty(N.ACCESS_CONTROL_ALLOW_HEADERS, req.httpProps[N.ACCESS_CONTROL_ALLOW_HEADERS]);
response.addHttpProperty(N.ACCESS_CONTROL_ALLOW_HEADERS, req.httpProps[N.ACCESS_CONTROL_REQUEST_HEADERS]);
response.addHttpProperty(N.ACCESS_CONTROL_MAX_AGE, req.cors.maxAgeInSeconds);
response.addHttpProperty(N.ACCESS_CONTROL_ALLOW_CREDENTIALS, true); // Refactor into response
res.set(response.httpProps);
res.status(200).send();
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/model/blob/AzuriteResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const uuidV1 = require('uuid/v1'),
EntityType = require('./../../core/Constants').StorageEntityType;

class AzuriteResponse {
constructor({ proxy = undefined, payload = undefined, query = {}, cors = undefined }) {
constructor({ proxy = undefined, payload = undefined, query = {}, cors = undefined } = {}) {
this.httpProps = {};
this.proxy = proxy;
if (this.proxy) {
Expand Down Expand Up @@ -34,6 +34,7 @@ class AzuriteResponse {
this.httpProps[N.ACCESS_CONTROL_ALLOW_ORIGIN] = cors.origin;
this.httpProps[N.ACCESS_CONTROL_EXPOSE_HEADERS] = cors.exposedHeaders;
this.httpProps[N.ACCESS_CONTROL_ALLOW_CREDENTIALS] = true;
this.httpProps[N.ACCESS_CONTROL_ALLOW_HEADERS] = cors.exposedHeaders;
}
}

Expand Down