Skip to content

Commit

Permalink
PWA Studio URL redirect not working (#4305)
Browse files Browse the repository at this point in the history
  • Loading branch information
glo11372 authored Aug 8, 2024
1 parent a3faf3f commit c35e41f
Showing 1 changed file with 61 additions and 0 deletions.
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'

0 comments on commit c35e41f

Please sign in to comment.