Strapi Blog Same-Origin Starter

by xaun

GitHub Readme.md

Strapi Blog Same-Origin Starter

This starter was bootstrapped from the strapi/strapi-starter-blog and strapi/strapi-starter-react-blog.

It provides you with a starter which is setup to serve the React blog from the same-origin as the strapi server.

My motivation for this starter:

  • Accessing the admin panel from the same-origin as the app is usually a preferred UX
  • Admin authentication session is accessible in the client making it easier to get started developing features like preview draft content before posting.
  • Quick & easy deployments to demo the CMS solutions to clients with the above points

To achieve this, the starter is configured with a custom Strapi Middleware to serve the client on /app and the admin on /admin.

The custom middleware is named clientView and is configured in the middleware config. The client only needs to be configured in one place, the package.json with a "homepage" setting to match the middleware config targetPath. This gets applied to the React Router basename.

To change the path the client is served on, change the middleware config targetPath, and the client/package.json homepage.

The middleware also sets a redirect on root "/" to targetPath.

Resource

Deploy

Additionally, this starter adds a heroku-postbuild script which ensure the admin and client are rebuilt on redeploy. The strapi/react-starter-blog fails to rebuild the admin build on subsequent deployments.

Deploy