Skip to content

Commit c5e652d

Browse files
authored
Add isCorsEnabled option (#28)
1 parent 7508777 commit c5e652d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ declare namespace electronServe {
1515
*/
1616
scheme?: string;
1717

18+
/**
19+
Whether [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) should be enabled.
20+
Useful for testing purposes.
21+
22+
@default true
23+
*/
24+
isCorsEnabled?: boolean;
25+
1826
/**
1927
The partition the protocol should be installed to, if you're not using Electron's default partition.
2028

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const getPath = async path_ => {
2525

2626
module.exports = options => {
2727
options = Object.assign({
28+
isCorsEnabled: true,
2829
scheme: 'app'
2930
}, options);
3031

@@ -57,7 +58,7 @@ module.exports = options => {
5758
secure: true,
5859
allowServiceWorkers: true,
5960
supportFetchAPI: true,
60-
corsEnabled: true
61+
corsEnabled: options.isCorsEnabled
6162
}
6263
}
6364
]);

readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ Default: `'app'`
5757

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

60+
##### isCorsEnabled
61+
62+
Type: `boolean`\
63+
Default: `true`
64+
65+
Whether [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) should be enabled.
66+
Useful for testing purposes.
67+
6068
##### partition
6169

6270
Type: `string`\

0 commit comments

Comments
 (0)