Transloco: Update PORT in the path to the translation files when changed

Created on 10 Sep 2019  路  6Comments  路  Source: ngneat/transloco

I'm submitting a...


[x] Bug report  

Current behavior

Even though the port used by ng serve was changed (via --port or angular.json), the library is still preserving the default one (4200) in the path to the translation files.

Expected behavior

Updating the port in the path to the translation files.

Minimal reproduction of the problem with instructions

Serve the example app via:
ng serve --port 4204

image

What is the motivation / use case for changing the behavior?

It is quite incovenient and could possibly cause some issues with ng-universal as it serves the app via 4000.

Environment


Angular version: 8.2.4

Most helpful comment

All 6 comments

@nulee We're adding the prefix only when you choose the SSR option in our schematics. Is this what you mean?

@shaharkazaz Yes, It is. Server version of the app is not able to load the translation files on its own. It is not that big of an issue as in the production environment you have typically build the browser version also. However, I don't see the motivation behind this, could you maybe elaborate?

@nulee
When working with SSR, you need to use the absolute path in the loader. In this case, we added a placeholder for you, which contains the standard port. You need to change it manually anyway for any other environment you have. We can't predict your base URL. You might even have a hosts file such as:
dev.company.com, localhost:4200

Sorry, there is nothing we can do about it. It's your responsibility to override the environment baseUrl property based on your application.

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

@shaharkazaz @NetanelBasal
Makes sense. Thank you for the lightning fast replies.
Would be nice to include this info in the README though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NetanelBasal picture NetanelBasal  路  6Comments

zufarzhan picture zufarzhan  路  3Comments

karmasakshi picture karmasakshi  路  6Comments

frct1 picture frct1  路  3Comments

inorganik picture inorganik  路  8Comments