mc9
mc9

Reputation: 6351

Static pages in the subfolders of React app

I would like to know how I can implement static pages under the subfolders of my server side rendered React application.

Currently, I have my-app.com which hosts my server side rendered React app, and blog.my-app.com which hosts a blog powered by static pages.

But I am going to move the blog to the subfolder of the root domain: my-app.com/blog. I would like the blog pages to be still based on static files. What approach can I take?

Upvotes: 1

Views: 721

Answers (1)

Ben Sidelinger
Ben Sidelinger

Reputation: 1359

If your serving the app with node, using something like express (which I imagine you are if your rendering a React app server side), then you can just use the servers build in static file serving capabilities by matching the /blog route. Here's the docs for express: https://expressjs.com/en/starter/static-files.html, Hapi, Koa and all the others have similar abilities. If you need to do some more complex route to file matching then you could use node fs to load files as strings respond with those strings.

Upvotes: 1

Related Questions