diff --git a/angular.json b/angular.json index 7b10856..1f95556 100644 --- a/angular.json +++ b/angular.json @@ -76,10 +76,12 @@ "builder": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { - "browserTarget": "frontend-hideyoshi.com:build:production" + "browserTarget": "frontend-hideyoshi.com:build:production", + "proxyConfig": "src/proxy.conf.json" }, "development": { - "browserTarget": "frontend-hideyoshi.com:build:development" + "browserTarget": "frontend-hideyoshi.com:build:development", + "proxyConfig": "src/proxy.conf.json" } }, "defaultConfiguration": "development" diff --git a/src/app/shared/auth/auth.service.ts b/src/app/shared/auth/auth.service.ts index 501b8ca..1d050bb 100644 --- a/src/app/shared/auth/auth.service.ts +++ b/src/app/shared/auth/auth.service.ts @@ -18,6 +18,8 @@ export class AuthService { readonly BACKEND_PATH = environment.backendPath; + readonly BACKEND_OAUTH_PATH = environment.backendOAuthPath; + constructor(private http: HttpClient) { } login(userAuthAtempt: User): void { @@ -25,11 +27,11 @@ export class AuthService { } googleLogin() { - window.open(this.BACKEND_PATH + '/oauth2/authorization/google', '_self'); + window.open(this.BACKEND_OAUTH_PATH + '/oauth2/authorization/google', '_self'); } githubLogin() { - window.open(this.BACKEND_PATH + '/oauth2/authorization/github', '_self'); + window.open(this.BACKEND_OAUTH_PATH + '/oauth2/authorization/github', '_self'); } loginGoogleUser(p: any): void { @@ -92,7 +94,7 @@ export class AuthService { ); return this.http.get( - this.BACKEND_PATH + '/login/oauth2/code/google', + this.BACKEND_OAUTH_PATH + '/login/oauth2/code/google', { withCredentials: true, params: params @@ -111,7 +113,7 @@ export class AuthService { ); return this.http.get( - this.BACKEND_PATH + '/login/oauth2/code/github', + this.BACKEND_OAUTH_PATH + '/login/oauth2/code/github', { withCredentials: true, params: params diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index ca31f52..d7ffeab 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,4 +1,5 @@ export const environment = { production: true, - backendPath: '/api' + backendPath: '/api', + backendOAuthPath: 'https://api.hideyoshi.com.br' }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index a5d8210..16454dd 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,7 +4,8 @@ export const environment = { production: false, - backendPath: 'http://localhost:8070' + backendPath: '/api', + backendOAuthPath: 'http://localhost:8070' }; /* diff --git a/src/proxy.conf.json b/src/proxy.conf.json new file mode 100644 index 0000000..2706673 --- /dev/null +++ b/src/proxy.conf.json @@ -0,0 +1,7 @@ +{ + "/api": { + "target": "http://localhost:8070", + "secure": false, + "pathRewrite": {"^/api" : ""} + } +} \ No newline at end of file