1

What I want to achieve is when I use the Angular / C# Web Api project in localhost and developing it I use this url in the Angular app:

http://localhost:5000/api/something

But this isn't working in deployment. I want to use the "/something" or something like that when the frontend and the backend is together.

atanii
  • 226
  • 2
  • 12
  • Possible duplicate of [How to set environment via \`ng serve\` in Angular 6](https://stackoverflow.com/questions/50174584/how-to-set-environment-via-ng-serve-in-angular-6) – Sreekumar P Apr 15 '19 at 10:16

1 Answers1

2

Under src directory create your environments:

enter image description here

export const environment = { production: false, apiUrl: 'http://localhost:5000/api/something', };

Angular command line tool knows which file to use for each environment.

Then import it:

import { environment } from '../../environments/environment';

And now use them in my classes as any other object:

apiUrl = environment.apiUrl;

Read more on the web

upkit
  • 327
  • 2
  • 11