Search code examples
htmlcssfontscors

CORS error loading a font in IntelliJ debugger


I have checked what I could find about font CORS errors (like CSS - Font being blocked from Cross-Origin Resource Sharing Policy), and it seems CORS errors are result of server mis-congiguration (or missing configuration).

I develop a web application. When I test it locally with my own server, it works fine. When I try a server-less version with IntelliJ IDEA debugger, which uses its own integrated web server, I get CORS error:

Access to font at 'https://code.cdn.mozilla.net/fonts/woff/FiraSans-Bold.woff' from origin 'http://localhost:63342' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Is this a bug in IntelliJ, or is there something missing in my page setup?

The error can be seen when debugging following HTML:

<html>
<head>
    <meta charset="UTF-8"/>
    <title>Loading...</title>
    <link href="https://code.cdn.mozilla.net/fonts/fira.css" rel="stylesheet"/>
    <style>
      h1 {
          font-family: "Fira Sans", sans-serif;
      }
    </style>
</head>
<body>
    <h1>Loading...</h1>
</body>

</html>

Solution

  • Maybe this can help you:

    "When debugging, the x-ijt header is sent for request signing to prevent requests from outside from being rejected; header is not sent if Allow unsigned requests in Settings | Build, Execution, Deployment | Debugger is enabled, so, if you are facing issues because of this header, you have to turn this option on"

    I found this answer on this page discussing CORS errors on IntelliJ IDEs