mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-08-04 14:37:34 +00:00
commit
a789c29a16
2 changed files with 14 additions and 16 deletions
|
|
@ -100,7 +100,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
|
||||
public getAccount(): Promise<Account> {
|
||||
console.info('Requesting account');
|
||||
return this.request<{account: Account}>('GET', 'account/').then((response) => {
|
||||
return this.request<{account: Account}>('GET', 'account').then((response) => {
|
||||
return response.account;
|
||||
});
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
|
||||
public getDroplet(dropletId: number): Promise<DropletInfo> {
|
||||
console.info('Requesting droplet');
|
||||
return this.request<{droplet: DropletInfo}>('GET', 'droplets/' + dropletId).then((response) => {
|
||||
return this.request<{droplet: DropletInfo}>('GET', 'droplets' + dropletId).then((response) => {
|
||||
return response.droplet;
|
||||
});
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
|
||||
public getDropletsByTag(tag: string): Promise<DropletInfo[]> {
|
||||
console.info('Requesting droplet by tag');
|
||||
return this.request<{droplets: DropletInfo[]}>('GET', `droplets/?tag_name=${encodeURI(tag)}`)
|
||||
return this.request<{droplets: DropletInfo[]}>('GET', `droplets?tag_name=${encodeURI(tag)}`)
|
||||
.then((response) => {
|
||||
return response.droplets;
|
||||
});
|
||||
|
|
@ -200,7 +200,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
|
||||
public getDroplets(): Promise<DropletInfo[]> {
|
||||
console.info('Requesting droplets');
|
||||
return this.request<{droplets: DropletInfo[]}>('GET', 'droplets/').then((response) => {
|
||||
return this.request<{droplets: DropletInfo[]}>('GET', 'droplets').then((response) => {
|
||||
return response.droplets;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,26 +147,24 @@ function getWebAppUrl() {
|
|||
// status code and inject CORS response headers.
|
||||
function workaroundDigitalOceanApiCors() {
|
||||
const headersFilter = {urls: ['https://api.digitalocean.com/*']};
|
||||
electron.session.defaultSession.webRequest.onHeadersReceived(
|
||||
// tslint:disable-next-line:no-any
|
||||
headersFilter, (details: any, callback: Function) => {
|
||||
electron.session.defaultSession.webRequest.onHeadersReceived(headersFilter,
|
||||
(details: electron.OnHeadersReceivedListenerDetails, callback: (response: electron.CallbackResponse) => void) => {
|
||||
if (details.method === 'OPTIONS') {
|
||||
details.responseHeaders['access-control-allow-origin'] = ['outline://web_app'];
|
||||
details.responseHeaders['access-control-allow-origin'] = 'outline://web_app';
|
||||
if (details.statusCode === 403) {
|
||||
details.statusCode = 200;
|
||||
details.statusLine = 'HTTP/1.1 200';
|
||||
details.responseHeaders['status'] = ['200'];
|
||||
details.responseHeaders['access-control-allow-headers'] =
|
||||
[details.headers['Access-Control-Request-Headers']];
|
||||
details.responseHeaders['access-control-allow-credentials'] = ['true'];
|
||||
details.responseHeaders['status'] = '200';
|
||||
details.responseHeaders['access-control-allow-headers'] = '*';
|
||||
details.responseHeaders['access-control-allow-credentials'] = 'true';
|
||||
details.responseHeaders['access-control-allow-methods'] =
|
||||
['GET, POST, PUT, PATCH, DELETE, OPTIONS'];
|
||||
'GET, POST, PUT, PATCH, DELETE, OPTIONS';
|
||||
details.responseHeaders['access-control-expose-headers'] =
|
||||
['RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, Total, Link'];
|
||||
details.responseHeaders['access-control-max-age'] = ['86400'];
|
||||
'RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, Total, Link';
|
||||
details.responseHeaders['access-control-max-age'] = '86400';
|
||||
}
|
||||
}
|
||||
callback(details);
|
||||
callback(details as electron.CallbackResponse);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue