Closed
Description
Pages Router
The PagesRouter
is a completely revamped router with many improvements over the current PublicAPIRouter
. It handles requests for password reset and email verification, and serves assets in the /public
directory such as webpages. It is an experimental replacement for the PublicAPIRouter
, so it is still disabled by default.
Features
- Inject dynamic content into any HTML site that could previously only be served as static asset.
- Localization of feature pages (password reset, email verification) and custom pages (any HTML page).
- Fully localized flow (email -> pages) for users in combination with the Parse Server API Mail Adapter.
- Easily add custom routes to customize the password reset or email verification flow or add new flows.
- Reduces network traffic by directly serving webpages instead of redirects.
- Customize the endpoint path and public directory.
Usage
Caution, this is an experimental feature that may not be appropriate for production.
To enable the PagesRouter
set the Parse Server configuration pages.enableRouter: true
. Set the other options if you want to use features such as localization.
new ParseServer({
...,
pages: {
enableRouter: true, // Enables the PageRouter by replacing the PublicAPIRouter; this is the general switch to turn on the experimental feature; default: false
enableLocalization: true, // Enables looking for locale matching page version on request; default: false
localizationJsonPath: './private/localization.json', // The path to the JSON file for localization; the translations will be used to fill template placeholders according to the locale.
localizationFallbackLocale: 'en', // The fallback locale for localization if no matching translation is provided for the given locale. This is only relevant when providing translation resources via JSON file.
placeholders: { aKey: 'aValue' }, // The placeholder keys and values which will be filled in pages; this can be a simple object or a callback function.
forceRedirect: false, // Enables always sending redirect responses and never sending content directly; default: false
pagesPath: './pages/', // A custom path to the page files; also sets where the '/apps' endpoint points to; default: './public'.
pagesEndpoint: 'pages', // A custom endpoint to the pages; also sets the '/apps' endpoint for password reset and email verification; default: 'apps'.
}
})
Factsheet
- Docs: Pages, Custom Routes
- Feature maturity: experimental
- Release status: unreleased (master branch)
- Pull request: Add page localization #7128
About
- This issue is only intended to inform. If you encounter a bug or have a suggestion please open a new issue.
- This is a pilot for a new series in which we move different notable feature addition or improvement into the spotlight.
- Got feedback regarding this series? - Post in the Community Forum.