Skip to content

Commit 2a67eed

Browse files
Add middleware option to override credentials prop
1 parent 4108ef9 commit 2a67eed

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Middleware supports the following properties:
158158
- `displayOptions` [`object`] - same as [here](#properties)
159159
- `headersJS` [`string`, default `"{}"`] - object of headers serialized in string to be used on endpoint url<BR>
160160
**Note:** You can also use any JS expression which results in an object with header names as keys and strings as values e.g. `{ Authorization: localStorage['Meteor.loginToken'] }`
161+
- `credentials` [`string`, default `include`] - the credentials read-only property of the Request interface indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests. Please refer to the [Request.credentials](https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials) page for more information.
161162

162163
### Express
163164

src/middleware/render-voyager-page.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ export interface MiddlewareOptions {
44
endpointUrl: string;
55
displayOptions?: object;
66
headersJS?: string;
7+
credentials?: string;
78
}
89

910
export default function renderVoyagerPage(options: MiddlewareOptions) {
10-
const { endpointUrl, displayOptions } = options;
11-
const headersJS = options.headersJS ? options.headersJS : '{}';
11+
const {
12+
endpointUrl,
13+
displayOptions,
14+
headersJS = '{}',
15+
credentials = 'include',
16+
} = options;
1217
return `
1318
<!DOCTYPE html>
1419
<html>
@@ -50,7 +55,7 @@ export default function renderVoyagerPage(options: MiddlewareOptions) {
5055
'Content-Type': 'application/json',
5156
}, ${headersJS}),
5257
body: JSON.stringify({query: introspectionQuery }),
53-
credentials: 'include',
58+
credentials: '${credentials}',
5459
}).then(function (response) {
5560
return response.text();
5661
}).then(function (responseBody) {

0 commit comments

Comments
 (0)