Sample: Frontend pages only

Overview

This example demonstrates how to configure your app for production to work exclusively with front-end pages. The middleware should be simplified by removing any unnecessary logic, particularly any logic related to backend pages.

Removing this disables the access to the instance's backend and should be done only to an environment that is meant to be public facing and needs its backend access restricted - like production for example. The idea here is that this approach allows for cleaner and faster processing of requests on the frontend and disables interactions with the backend on that instance. Content and widgets implementations should be handled in that environment via CI and CD and utilizing Sitefinity SiteSync.

PREREQUISITES: You must set up a Sitefinity renderer application and connect it to your Sitefinity CMS application. For more information, see Install Sitefinity in Next.js mode.

Removing backend middleware

To remove the backend middleware check from the middleware.ts file, remove the section below:

const resultBackend = await middlewareBackend(request); if (resultBackend instanceof NextResponse || resultBackend instanceof Response) { return resultBackend; }

Full frontend only middleware sample

This is how the middleware.ts file looks like without the backend check:

Run the sample

This sample is available in Sitefinity’s GitHub repository. You can run and play with it.
To do this, perform the following:

  1. Go to Sitefinity’s GitHub repository Sitefinity Next.js samples.
  2. Expand Code and click Download ZIP.
  3. Extract the files on your computer.
  4. In the extracted folder, navigate to \nextjs-samples-main\nextjs-samples-main\src\fe-pages-only folder.
  5. In the command console run npm install.
  6. Open the .env.development file.
  7. In section PROXY SETTINGS, change the SF_CMS_URL property to the URL of your Sitefinity CMS site.
    If you have deployed Sitefinity CMS on the IIS, point to https://localhost:<https_port>.
  8. If your Sitefinity CMS is hosted on the cloud, in SF_LOCAL_VALIDATION_KEY= add your validation key. For more information, see Set up the project for local development (using Next.js Renderer).
  9. In the command console run npm run dev.


Want to learn more?

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?