Skip to content

Commit

Permalink
Add isCorsEnabled option (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflorian committed Jan 20, 2021
1 parent 7508777 commit c5e652d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ declare namespace electronServe {
*/
scheme?: string;

/**
Whether [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) should be enabled.
Useful for testing purposes.
@default true
*/
isCorsEnabled?: boolean;

/**
The partition the protocol should be installed to, if you're not using Electron's default partition.
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const getPath = async path_ => {

module.exports = options => {
options = Object.assign({
isCorsEnabled: true,
scheme: 'app'
}, options);

Expand Down Expand Up @@ -57,7 +58,7 @@ module.exports = options => {
secure: true,
allowServiceWorkers: true,
supportFetchAPI: true,
corsEnabled: true
corsEnabled: options.isCorsEnabled
}
}
]);
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ Default: `'app'`

Custom scheme. For example, `foo` results in your `directory` being available at `foo://-`.

##### isCorsEnabled

Type: `boolean`\
Default: `true`

Whether [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) should be enabled.
Useful for testing purposes.

##### partition

Type: `string`\
Expand Down

0 comments on commit c5e652d

Please sign in to comment.