APM Hosted Content WOFF(2) mimetype

Hi there,

I am creating a customised logon page for APM and am using hosted content for css, images etc. When uploading fonts I can host SVG and TrueType but there is no mimetype for WOFF or WOFF2. I’m running on 12.1.x.

Is there a way to make this work easily, or should I just exclude them.

Cheers

Yes, this is easy. In your ‘HTTP::respond’ set the ‘Content-Type’ to ‘font/woff’ or ‘font/woff2’. See a code example below.

when RULE_INIT {
    set static::html {
        <!DOCTYPE html>
        <html>
          <head>
            <style> 
                @font-face {
                  font-family: myFirstFont;
                  src: url(font.woff);
                }
 
                div {
                  font-family: myFirstFont;
                }
            </style>
          </head>
        <body>
 
        <h1>The @font-face Rule</h1>
 
        <div>With CSS, websites can finally use fonts other than the pre selected "web-safe" fonts.</div>
 
        <p><b>Note:</b> Internet Explorer 8 and earlier, do not support the WOFF format (only supports EOT format).</p>
 
        </body>
        </html>
    }
}
 
when HTTP_REQUEST {
    if { [HTTP::uri] eq "/test" } {
        HTTP::respond 200 content $static::html
    }
    if { [HTTP::uri] eq "/font.woff" } {
        HTTP::respond 200 content [ifile get font.woff] Content-Type "font/woff" Cache-Control "max-age=0,must-revalidate"
    }
}

This should result in something like this:

Thanks Niels. Actually turns out you can just manually type in the mimetype under hosted content (even if it’s not listed).