Excluding Certain Path From Frontity Routing To Allow Server Side Response for "Let's Encrypt" Challenge

Hey,

First post, so excuse any faux pas.

Iā€™ve got a pretty good grip of the basics and had deployed my site properly.

That site was hosted on SpinupWP, which for the most part I canā€™t recommend enough.

They had a pretty handy function to allow you to enable an automated script of Certbot to create and get an authorised SSL certificate from Letā€™s Encrypt.

However, to allow this to happen, the Letā€™s Encrypt service needs to send a challenge to a specific sub-directory ā€˜example.com/.well-known/acme-challenge/ā€™ and expects to find a text file containing a fingerprint on the server.

For the quick amongst you, you can probably already see the issue that Iā€™ve got.

Frontity/React is capturing all URLs and routing it on the client-side - so that path is returning a 404 from the client-side and never reaching the server side.

I need to exclude that directory from the routing of frontity/react otherwise I canā€™t get an SSL certificate and my website ā€œonepixelwide.co.ukā€ will not load.

After a couple of days of googling and prodding around to realise it wasnā€™t an Nginx/Ubuntu server issue, Iā€™m now trying to see if itā€™s possible to allow certain paths to head to be excluded by Frontity.

Firstly, I hope the above made sense, and secondly, any help would be massively appreciated.

Thanks,

Peter

Hi @OnePixelWide! Iā€™m currently working on the server extensibility, which would allow you to set custom middleware to the Koa server that runs Frontity. In the meanwhile, however, a workaround is to create a node server and set handlers before Frontity. You can access frontity from the server like this:

const frontity = require("./build/server");

server((req, res) => frontity.default(req, res));

I hope this points you in the right direction, at least until the server extensibility is released.

1 Like

Hi @orballo, thanks for getting back to me. Funnily enough, I found the discussion about server extensibility after I posted this. I ended up adding an Nginx location rule ahead of the proxy, seems to do the trick, but itā€™s good to know there is a workaround and the functionality is coming. Thanks for all your effort.