Support » Plugin: Autoptimize » Cross-Origin Read Blocking (CORB) blocked

  • Resolved wlpdrpat

    (@wlpdrpat)


    Hi Frank,

    I recently updated to the latest version and have run into the following issue.

    My configuration uses the Inline and defer css. I use the criticalcss.com to generate the inline css.

    The deferred style sheets are trying to be delivered via my CDN but are being blocked. I am getting the following error message when inspecting on Chrome:

    Cross-Origin Read Blocking (CORB) blocked cross-origin response https://mychirocdn.r.worldssl.net/wp-content/cache/autoptimize/579/css/autoptimize_fcb4c65254ba3b6544b5279f173e86c8.css with MIME type text/html.

    It looks like the <link doesn’t include the type=”text/css” and as a result it is being considered at text/html.

    Any suggestions to resolve this?

    Thanks,
    Pat

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    The problem more likely is the fact that the response, in fact, is HTML and not the optimized CSS?

    wlpdrpat

    (@wlpdrpat)

    I figured. I contacted my CDN provider to see what the issue is with delivering it. I checked several other sites and they are not getting the same error – so something about the particular site it is being generated on. Very strange as the CDN has been great until this issue.

    • This reply was modified 11 months ago by wlpdrpat.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    and is the CSS-file available at your origin site?

    wlpdrpat

    (@wlpdrpat)

    Yes the file is available via the origin.

    It is also available on the CDN if I add a version.

    Not available:
    https://mychirocdn.r.worldssl.net/wp-content/cache/autoptimize/579/css/autoptimize_32ef64ae4506c5047492248bb98e993a.css

    Available:
    https://mychirocdn.r.worldssl.net/wp-content/cache/autoptimize/579/css/autoptimize_32ef64ae4506c5047492248bb98e993a.css?ver=4.9.10

    I checked a few of the other resources where I was getting a similar error and in each case if I add a version number the resource is available.

    Would it be difficult to add a version number to the URL? E.g. the plugin version number.

    wlpdrpat

    (@wlpdrpat)

    As a quick fix for my situation I did the following to /classes/autoptimizeStyles.php

    Add Line 857:
    $ver = AUTOPTIMIZE_PLUGIN_VERSION;

    Modify Line 862:
    $preloadCssBlock .= '<link rel="preload" as="style" media="' . $media . '" href="' . $url . '?ver=' . $ver . '" onload="' . $preloadOnLoad . '" />';

    Modify Line 863:
    $noScriptCssBlock .= '<link type="text/css" media="' . $media . '" href="' . $url . '?ver=' . $ver . '" rel="stylesheet" />';

    Modify Line 867:
    $this->inject_in_html( '<link type="text/css" media="' . $media . '" href="' . $url . '?ver=' . $ver . '" rel="stylesheet" />', $replaceTag );

    That added the plugin version to the css URLs.
    and /classes/autoptimizeScripts.php

    Add Line 388:
    $ver = AUTOPTIMIZE_PLUGIN_VERSION;

    Modify Line 389:
    $bodyreplacementpayload = '<script type="text/javascript" ' . $defer . 'src="' . $this->url . '?ver=' . $ver . '"></script>';

    That takes care of adding version to the main js payload.

    It may not be perfect but it resolved my situation.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    You _could_ do that (and you could even hook into the AO API to avoid changing the plugin’s code which will get overwritten when I release AO25 mid April), but I would rather work on fixing the root problem with the CDN-support staff to be honest @wlpdrpat 🙂

    wlpdrpat

    (@wlpdrpat)

    @optimizingmatters Agreed. The challenge is the CDN support was unable to reproduce the issue and I needed to keep a client happy in a hurry (imagine what the site looks like without css).

    How would I hook into the AO API to make these changes? I would definitely prefer to do that compared to changing core files that get overwritten.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Well, if you’re into coding you could try hooking into the autoptimize_html_after_minify filter and regex replace the wp-content/cache/autoptimize/ url’s.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Cross-Origin Read Blocking (CORB) blocked’ is closed to new replies.