Search:   Dictionary All Posts
Store Your Knowledge at the Brain Bank!

Serve Static File .txt, .html. via React Router

By Jamie in Lessons / Programming - React  3.1.19  
Summary - Server robots.txt file, certbot verifcation file, or other plain html or other pages using this React Router trick...
add the file you want to the public folder, then in your routes file (app.js or index.js) put...

const reload = () => window.location.reload();

<Route path="/robots.ext" onEnter={reload} />

now we can use certbot to verify our SSL certificate since we can serve the verification file they require. no need to pay for it anymore. see certbot instructions and add the page using the above method