Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWA Studio URL redirect not working #4305

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions packages/venia-ui/upward.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ veniaResponse:
- matches: fileExtension
pattern: '(js|json|png|jpg|gif|svg|ico|css|txt)'
use: veniaStatic
- matches: urlResolver.redirect_code
pattern: '301'
use: dynamicRedirect
default: veniaAppShell

# A FileResolver for serving certain files directly from document root,
Expand Down Expand Up @@ -195,3 +198,61 @@ veniaStaticIncludes:
directory:
resolver: inline
inline: './venia-static'

urlResolver: urlResolverResult.data.route

urlResolverResult:
resolver: service
endpoint:
resolver: url
baseUrl: env.MAGENTO_BACKEND_URL
pathname:
inline: graphql
method:
resolver: inline
inline: POST
headers:
resolver: inline
inline:
'content-type': 'application/json'
accept: 'application/json'
query:
resolver: inline
inline: 'query ResolveURL($url: String!) {
route(url: $url) {
type
relative_url
redirect_code
}
}'
variables:
resolver: inline
inline:
# This is a barestring indicating a context lookup. It resolves to the
# `path` value in the URL query string of the request, using the builtin
# `request` context object.
url: request.url.pathname

dynamicRedirect:
resolver: inline
inline:
status: urlResolver.redirect_code
headers:
resolver: inline
inline:
content-type:
inline: text/html
cache-control:
inline: s-maxage=60
body:
resolver: template
engine: mustache
provide:
pageType: veniaPageType.data
pageTypeNonce: veniaPageTypeNonce.nonce
webpackChunks: veniaWebpackChunks.scripts
template:
resolver: file
file:
resolver: inline
inline: './index.html'
Loading