Skip to content

Commit

Permalink
Merge pull request #7 from Qihoo360/feature/frontend-separate
Browse files Browse the repository at this point in the history
frontend: add base-url
  • Loading branch information
70data authored Jun 5, 2019
2 parents 6cd6ac0 + 877851c commit a807b47
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --disable-host-check --proxy-config proxy.config.js --configuration hmr",
"build": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --aot --prod --build-optimizer --base-href \"/public/\"",
"start": "ng serve --host 0.0.0.0 --disable-host-check --configuration hmr",
"build": "node --max_old_space_size=6000 ./node_modules/@angular/cli/bin/ng build --aot --prod --build-optimizer",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
Expand Down
13 changes: 11 additions & 2 deletions src/frontend/src/app/shared/interceptor/auth-interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ import { from } from 'rxjs';
import { HttpEvent, HttpHandler, HttpHeaders, HttpInterceptor, HttpRequest } from '@angular/common/http';
import 'rxjs/add/observable/fromPromise';
import { LoginTokenKey } from '../shared.const';

import { resolve } from 'url';
import { DEV_URL, MASTER_URL } from '../../../base-url';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
baseUrl = 'http://test.qihoo.cloud';
constructor() {
}

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return from(this.handleAccess(request, next));
const apiReq = request.clone({
url: resolve(request.url.indexOf('assets/') > -1
? '/'
: process.env.NODE_ENV === 'development'
? DEV_URL
: MASTER_URL, request.url)
});
return from(this.handleAccess(apiReq, next));
}

private async handleAccess(request: HttpRequest<any>, next: HttpHandler):
Expand Down
8 changes: 8 additions & 0 deletions src/frontend/src/base-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const DEV_URL = 'http://10.16.111.156:8080';
// const DEV_URL = 'http://www.test.qihoo.cloud';
const MASTER_URL = 'https://www.qihoo.cloud';

export {
DEV_URL,
MASTER_URL
};

0 comments on commit a807b47

Please sign in to comment.