Getting ready
Let's use HTTP headers to enhance our Express route configurations. For our API routes, we will add headers to enable CORS via pre-flight OPTIONS requests. This will come in handy if we ever need to run our API on a different domain than our Angular web application.
For our Angular routes, we will read the incoming Accept-Language header and parse it into a locale property that we can inject into our index.html file's locale definition. This will leverage the existing internationalization work we have for our Angular app and allow us to set the displayed language in our frontend from our backend web server using headers.
To do the parsing and injection of the script tag for our index.html file, we will use a lightweight DOM ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access