Skip to content

Commit

Permalink
fix: remote source for web
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Jun 28, 2022
1 parent 952d092 commit 5e53f2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { NzMessageService } from 'ng-zorro-antd/message';
<p>Localhost: Store the data locally. You can only use the product on the current computer.</p>
<p>
Remote Server: Store data on a remote server to facilitate cross device use of the product.
<a href="" class="text-blue-400">Learn more...</a>
<a href="https://eoapi.io/docs/storage.html" target="_blank" class="eo_link"> Learn more...</a>
</p>
</div>
</nz-form-item>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { filter, map, Observable } from "rxjs";
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/remote/remote.service';
import { filter, map, Observable } from 'rxjs';
const protocolReg = new RegExp('^(http|https)://');

// implements StorageInterface
@Injectable()
export class BaseUrlInterceptor implements HttpInterceptor {
export class BaseUrlInterceptor extends RemoteService implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const { url = '', token = '' } = window.eo?.getModuleSettings?.('eoapi-common.remoteServer') || {};
const { url = '', token = '' } = this.getConfiguration('eoapi-common.remoteServer') || {};
req = req.clone({
url: protocolReg.test(req.url) ? req.url : url + req.url,
headers: req.headers.append('x-api-key', token),
Expand All @@ -18,4 +19,4 @@ export class BaseUrlInterceptor implements HttpInterceptor {
map((event: HttpResponse<any>) => event.clone({ body: { status: 200, data: event.body.data } }))
);
}
}
}

0 comments on commit 5e53f2a

Please sign in to comment.