Setting up a fallback

Hi, Regarding this kind of incident, Is there a way to set up a fallback for CDN?

Since I found these alternatives, I want to know how to set up a fallback with ghost configuration.

Alternative #1: change subdomain into something else like fastly, gcore, etc.

Alternatnive #2: Use unpkg

If setting up fallback is unavailable at this moment, is there a plan to add this in ghost roadmap?
Or, since this kind of CDN certificate error is uncommon, Should I ignore it?

In my theme I do this over “npm install @tryghost/sodo-search” and “npm install @tryghost/portal”

Then I copy those files with gulp to assets/jsdelivr/…

function copy(done) {
    [
        src('node_modules/@tryghost/sodo-search/umd/main.css').pipe(dest('assets/jsdelivr/sodo-search')),
        src('node_modules/@tryghost/sodo-search/umd/sodo-search.min.js').pipe(dest('assets/jsdelivr/sodo-search')),
        src('node_modules/@tryghost/portal/umd/portal.min.js').pipe(dest('assets/jsdelivr/')),
        src('node_modules/@fontsource/source-sans-pro/**/*').pipe(dest('assets/fonts/source-sans-pro')),
        src('node_modules/@fontsource/merriweather/**/*').pipe(dest('assets/fonts/merriweather')),
        done()
    ];
}

At last I added these lines to config.production.conf:

  "sodoSearch": {
    "url": "/assets/jsdelivr/sodo-search/sodo-search.min.js",
    "styles": "/assets/jsdelivr/sodo-search/main.css"
  },
  "portal": {
    "url": "/assets/jsdelivr/portal.min.js"
  }

Hope this helps.

1 Like

Thank you for your prompt reply and even ping me in the ghost chat!
Since I’m maintaining the blog without front-end side knowledge… this really helped me a lot.

If my understanding is right,
this action is to include the javascript files within my assets and replacing the config with that javascript file, so that my blog doesn’t have to send request to CDN servers.

And if there’s an update on sodo-search(or other js files also) ,
what I have to do is 1) npm update @tryghost/sodo-search 2) copy updated files to assets/jsdelivr

That’s convenient.

Here I have an additional question, Isn’t sodo-search is now inside the app directory of the tryghost repository, instead of being independent npm package?

Do you think I can still apply update with npm?

@bjang for self hosted Ghost I found a even better solution :slight_smile:

1 Like

Ghost has a monorepo, meaning there are multiple packages together on GitHub. You can still get it as an npm package, I think. But easier would be to just download the built version from jsdelivr. No build step needed that way.

1 Like