0

We need to activate the SSR on an angular application for SEO purposes. For that, we followed this tutorial perfectly.

But when we try to access the application, we get an internal error 500 error message

Content Security Policy: The page settings have prevented a resource from loading at http://test/favicon.ico ("default-src")

Even though we have removed the favicon from our application

index.html

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Test</title>
      <base href="/">
      <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
      <app-root></app-root>
    </body>
    </html>

Here is the web.config at the root of our IIS server

web.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <add name="iisnode" path="main.js" verb="*" modules="iisnode" />
        </handlers>
        <rewrite>
          <rules>
            <rule name="DynamicContent">
              <match url="/*" />
              <action type="Rewrite" url="dist\test\server\main.js"/>
            </rule>
            <rule name="StaticContent" stopProcessing="true">
              <match url="([\S]+[.](jpg|jpeg|gif|css|png|js|ts|cscc|less|ico|html|map|svg))" />
              <action type="None" />
            </rule>
          </rules>
        </rewrite>
        <staticContent>
          <clientCache cacheControlMode="UseMaxAge" />
          <remove fileExtension=".svg" />
          <remove fileExtension=".eot" />
          <remove fileExtension=".ttf" />
          <remove fileExtension=".woff" />
          <remove fileExtension=".woff2" />
          <remove fileExtension=".otf" />
          <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
          <mimeMap fileExtension=".svg" mimeType="image/svg+xml"  />
          <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
          <mimeMap fileExtension=".woff" mimeType="application/x-woff" />
          <mimeMap fileExtension=".woff2" mimeType="application/x-woff" />
          <mimeMap fileExtension=".otf" mimeType="application/otf" />
        </staticContent>
        <iisnode nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />
      </system.webServer>
    </configuration>

Also, if you have any information on how to set up the side rendering server with the following stack: Frontend Angular, Backend .netcore 6 WebAPI & IIS for host it's with pleasure, we don't find a lot of information about it

sylvaing
  • 7
  • 6

0 Answers0