Skip to content

Commit

Permalink
Merge pull request #24 from samuikaze/dev
Browse files Browse the repository at this point in the history
Merge into main branch
  • Loading branch information
samuikaze committed Sep 17, 2023
2 parents 93ef027 + de00c35 commit 83e15e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable, inject, isDevMode } from '@angular/core';
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { RequestService } from '../request-service/request.service';

@Injectable({
providedIn: 'root',
})
export class AppEnvironmentService {
private configFromJson?: any = undefined;
constructor(private httpClient: HttpClient) {}
constructor(private requestService: RequestService) {}

/**
* 從 assets/configs.json 取得設定值
*/
public retrievingConfigsFromJson(): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
this.httpClient.get('/assets/configs.json').subscribe({
this.requestService.get<any>('/assets/configs.json').subscribe({
next: (response) => {
this.configFromJson = response;
resolve(true);
Expand Down
8 changes: 4 additions & 4 deletions src/app/services/request-service/request.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export class RequestService {
}

const protocol = `${location.protocol}//`
const hostname = location.hostname;
const path = location.pathname;
const uri = originalUri.substring(1);
const hostname = location.host;
const path = location.pathname === '/' ? '' : location.pathname;
const uri = (originalUri.indexOf('/') === 0) ? `/${originalUri.substring(1)}` : originalUri;

return `${protocol}${hostname}${path}/${uri}`;
return `${protocol}${hostname}${path}${uri}`;
}

/**
Expand Down

0 comments on commit 83e15e9

Please sign in to comment.