incubator-llc / prior-notify
PriorNotify 模块用于将所有前端请求通过 UPWARD-PHP 进行路由。
Requires
- php: ~7.3.0||~7.4.0
- liquid/liquid: ^1.4.8
- magento/framework: *
- magento/module-config: *
- magento/module-integration: 2.0.0
- magento/module-store: *
- magento/upward: *
- yireo/magento2-disable-service-worker-in-admin: ^0.0.2
This package is not auto-updated.
Last update: 2024-09-26 23:20:22 UTC
README
The Magento 2 UPWARD connector is a module for routing requests to UPWARD-PHP. This module replaces the default Magento frontend theme with a PWA Studio storefront application.
PWA Studio storefront deployments in the Magento Commerce Cloud use this module to keep Magento and storefront code on the same server.
安装
The Magento 2 UPWARD connector module is part of the Magento Cloud deployment steps in the official PWA Studio docs.
配置
The Magento 2 UPWARD connector has additional settings that can be configured in the admin area under
Stores > Configuration > General > Web > UPWARD PWA Configuration.
常规配置
这是 UPWARD 流程本身的配置。
UPWARD 配置文件
This configuration is the location of the UPWARD configuration file for the UPWARD-PHP server. It is recommended you follow system-specific best practices and set this value with an environment variable or the magento config:set
CLI command.
You may use a path relative to your web root or an absolute path for the value of this configuration.
Relative: fastcgi_param CONFIG__DEFAULT__WEB__UPWARD__PATH pwa/upward.yml
Absolute: magento config:set -e web/upward/path /app/node_modules/@magento/venia-concept/dist/upward.yml
前端名称允许列表
This configuration allows you to specify a line-separated list of routes to forward to the default Magento theme.
示例
contact
privacy-policy-cookie-restriction-mode
With this example, when a visitor navigates to either <Magento store URL>/contact
or <Magento store URL>/privacy-policy-cookie-restriction-mode
, they will land on a page rendered by Magento instead of the storefront application.
Prerender.io 配置
Prerender.io support in the upward-connector module allows your site to send prerendered static html to search bots.
A middleware layer checks each request to see if it comes from a crawler and if allowed, sends it to the prerender service. These configuration entries let you configure which pages to send to Prerender.io to serve the static HTML versions of that page. If a page is not configured for prerendering, the request continues using the normal server routes.
测试预渲染页面
To see how a crawler sees a prerendered page, set your browser's User Agent to Googlebot
and visit your URL. You can also run this on the command line and change the sample URL to your storefront's URL
curl -A Googlebot https://www.example.com/ > page.html
To configure prerender locally for testing purposes, see https://docs.prerender.io/test-it/.
处理部分渲染页面的问题
There is no way to tell when a PWA page fully loads. For prerendering it is possible to force prerender to wait for a predefined timeout before setting the window.prerenderReady
flag.
Add the following to the runtime script
window.prerenderReady = false; setTimeout(function () { window.prerenderReady = true; }, 1000 * 15);
For more information, see https://docs.prerender.io/test-it/.
Service Worker 注意事项
请避免在您的PWA Studio店面和Magento 2管理后端之间共享相同的主机名。这会导致当您在同一浏览器上同时打开店面和管理标签页时,店面Service Worker会拦截后端请求。如果您无法避免共享主机名,每次只访问一个服务,或者为每个服务使用一个私密浏览会话。