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 manipulation library called Cheerio. You will need to install Cheerio to your package.json file in order to import it:

npm install cheerio --save
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.112.82