Skip to content

Commit

Permalink
Clarified BACKEND_URL to BACKEND_URL_OVERRIDE
Browse files Browse the repository at this point in the history
  • Loading branch information
oktaal committed Aug 3, 2024
1 parent c79cd71 commit b7d211b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
import { provideServerRendering } from '@angular/platform-server';
import { BACKEND_URL, appConfig } from './app.config';
import { BACKEND_URL_OVERRIDE, appConfig } from './app.config';

const serverConfig: ApplicationConfig = {
providers: [
provideServerRendering(),
{ provide: BACKEND_URL, useValue: 'http://localhost:8000/api/' }
{ provide: BACKEND_URL_OVERRIDE, useValue: 'http://localhost:{{cookiecutter.backend_port}}/api/' }
]
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { routes } from './app.routes';
* https://github.com/angular/angular-cli/issues/27144
* By default it is empty, because in the browser this isn't needed
*/
export const BACKEND_URL = new InjectionToken<string | null>('BackendUrl', {
export const BACKEND_URL_OVERRIDE = new InjectionToken<string | null>('BackendUrl', {
factory: () => null
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { lastValueFrom } from 'rxjs';
import { ConfigService } from './config.service';
import { BACKEND_URL } from '../app.config';
import { BACKEND_URL_OVERRIDE } from '../app.config';


@Injectable({
Expand All @@ -17,7 +17,7 @@ export class BackendService {
/**
* Override BACKEND_URL for SSR
*/
@Inject(BACKEND_URL) private backendUrl: string) {
@Inject(BACKEND_URL_OVERRIDE) private backendUrlOverride: string) {
}

/**
Expand All @@ -40,7 +40,7 @@ export class BackendService {

getApiUrl(): Promise<string> {
if (!this.apiUrl) {
this.apiUrl = this.config.get().then(config => this.backendUrl ?? config.backendUrl);
this.apiUrl = this.config.get().then(config => this.backendUrlOverride ?? config.backendUrl);
}

return this.apiUrl;
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.slug}}/package.angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"watch-front-p": "yarn front yarn watch",
"start-back-p": "cd backend && python manage.py runserver --settings production --insecure --pythonpath ..",
"start-p": "yarn start-back-p & sleep 5 && yarn static-p && yarn watch-front-p",
"stop-back": "lsof -t -i tcp:8000 | xargs kill -9 || echo \"not running\""
"stop-back": "lsof -t -i tcp:{{cookiecutter.backend_port}} | xargs kill -9 || echo \"not running\""
},
"devDependencies": {
"@angular/cli": ">=17 <18"
Expand Down

0 comments on commit b7d211b

Please sign in to comment.