How to properly add the base url both in environment.prod.ts and environment.ts (Angular)?

Published

This question is related to a full stack spring boot + angular application.

Spring boot:

I have the following URL in my getMapping method:

http://localhost:8000/conversion

Angular service:

I have the following method to consume the spring boot services:

  retrieveAllRates(){
    return this.http.get<RatesList[]>(`${URL_PATH}/conversion`);
  }

In my environment.ts file I have:

export const environment = {
  production: false,
  baseUrl: 'http://localhost:8000'
};

In my environment.prod.ts file I have:

export const environment = {
  production: true,
  baseUrl: 'http://EXAMPLE_DOMAIN.com'
};

This is causing some issues because in production environment "http://EXAMPLE_DOMAIN.com/conversion" is not recognized throwing a 404 http error.

Based on the data provided, what would be the correct base url in environment.prod.ts for it to work in production environment?

Source: Angular Questions

Published
Categorized as angular, spring-boot, vps Tagged , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq