This project is not covered by Drupal’s security advisory policy.
Frontend editing module for a headless nextjs frontend
This module is paired with a module in the frontend of a nextjs page.
With these 2 modules it is possible to edit the content in the frontend within a headless environment.
Requirements for the frontend
Configuration
add these values to the .env file in the root of the project.
NEXTJS_DOMAIN=http://localhost:3000
NEXTJS_REVALIDATE_SECRET=FAKESECRET
PREVIEW_URL=http://localhost:3000
JWT_TOKEN=FAKETOKENif a jwt already exists, it is possibble that your jwt_token has a different way of configuration, for example in another file.
steps
- If a Page Preview module already exists, make sure to disable this.
- Run
composer require 'drupal/fe_editing_nextjs:^1.0@beta' - Make sure this module, the JWT Path Authentication module and the allow site iframing module are enabled.
- go to admin/settings/system/JWT_authentication and click the tab JWT Path
- Authentication, add the following path:
/frontend-editing/ - go to admin/config/system/allowed_iframed_sites and add the url from the frontend. (or localhost if local)
-
go to admin/config/system/keys and add a new key with the following settings:
key type = JWT HMAC KeyJWT Algorithm = HMAC using SHA-256 (HS256)Key Provider EnvironmentEvironment Variable = JWT_TOKEN
- check the patches folder for patches applied to the /includes/html.theme file, if the following code exists, in there.. delete it (or disable the patch).
$route_name = \Drupal::routeMatch()->getRouteName(); if ($route_name === 'entity.node.canonical') { $url = Url::fromRoute('<current>')->toString(); $url = Url::fromUserInput("/api/preview?path=$url")->setAbsolute()->toString(); $fe_url = Settings::get('burst_theme_frontend_url')($url); $override = \Drupal::state()->get('fe_url_override'); if ($override) { $path = Url::fromRoute('<current>')->toString(); $fe_url = $override . "/api/preview?path=$path"; } if (function_exists('page_preview_token_generate')) { $fe_url = $fe_url . '&token=' . page_preview_token_generate(); } if ($url !== $fe_url) { $variables['page']['content']['burst_theme_content'] = [ '#type' => 'inline_template', '#template' => ' <div id="frontend-iframe-container"> <a href="' . $fe_url . '" class="button button--primary" target="_blank">' . t('Preview page') . '</a> <iframe src="{{ url }}" id="frontend-iframe"></iframe> </div> ', '#context' => [ 'url' => $fe_url, ], '#attached' => [ 'library' => ['burst_theme/frontend-iframe'] ] ]; }
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Accessibility, Content editing experience, Content display
- Ecosystem: Paragraphs, Allow site iframing, JSON Web Token Authentication (JWT)
- Created by Burst on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
