I am looking to migrate existing nginx setup to Digitalocean App Platform.
What i have now is www.example.com/en/index.html and www.example.com/de/index.html serving english and de version respectively. What is the best way to achieve this in app platform?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
3 answers

To further clarify we are using angular 11 which compiles two instances of same application /dist/en and /dist/de

  • Hi again @brankoilicc, I was taking a look at this since you mentioned it in the other question and I was curious. If you were to set the output directory to dist, would that not work? If there’s any special handling in the nginx config, can you share it?

👋 @brankoilicc

In your follow up comment I see you’re using Angular. Using the Angular Router an app can create routes on the client side directly to the en and de variants. For example, you could detect the language set in the users browser then direct them to the appropriate site with this router module. This is probably the best solution.

Alternatively, you could create an app with two static site components that point to the same git repository. These sites will be the en and de versions. You will need to update the HTTP Route and the Output Directory for both versions. When accessing example.com/en it will go to the index.html in dist/en and when accessing example.com/de it will go to the index.html in dist/de.

You could also the root route (/) to one of these so that example.com will show the en or de version based on your preference.

Hello @crashoverride
I cant make a frontend router route to different language because those are 2 separate apps. /en/ and /de/ i guess i could somehow make it work to route from one app to another? but im not sure how atm heh

That leaves me with option two. Only problem is how do i prevent App Platform for compiling my code twice? because i use prerendering my compile time is 18 minutes.

I have already created a small script that copies /en/ folder content to /dist/browser. Now i have /dist/browser for english and /dist/browser/de/ for de.

Will try it out tomorrow and let you know.