Skip to content

Commit

Permalink
Add middleware option to override credentials prop
Browse files Browse the repository at this point in the history
  • Loading branch information
iuliiasobolevska-indeed committed Feb 25, 2021
1 parent 4108ef9 commit acaf4d4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/middleware/render-voyager-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ export interface MiddlewareOptions {
endpointUrl: string;
displayOptions?: object;
headersJS?: string;
credentials?: string;
}

export default function renderVoyagerPage(options: MiddlewareOptions) {
const { endpointUrl, displayOptions } = options;
const headersJS = options.headersJS ? options.headersJS : '{}';
const {
endpointUrl,
displayOptions,
headersJS = '{}',
credentials = 'include',
} = options;
return `
<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -50,7 +55,7 @@ export default function renderVoyagerPage(options: MiddlewareOptions) {
'Content-Type': 'application/json',
}, ${headersJS}),
body: JSON.stringify({query: introspectionQuery }),
credentials: 'include',
credentials: '${credentials}',
}).then(function (response) {
return response.text();
}).then(function (responseBody) {
Expand Down

0 comments on commit acaf4d4

Please sign in to comment.