faustjs icon indicating copy to clipboard operation
faustjs copied to clipboard

Bug: Sitemap URLs rewrite to locahost:8080 on Atlas

Open JEverhart383 opened this issue 3 years ago • 0 comments

This issue was initially reported by a user in discord and confirmed by me using the Faust starter using both the default WP sitemaps and the drop in Yoast config available on the docs. When proxying sitemaps via Next.js middleware on the Atlas platform, the value of req.url.origin is localhost:8080 and not the actual front end URL of the site, so that is what gets rewritten when we replaceUrls.

Applicable Versions

  • @faustjs/core version: 0.15.6
  • @faustjs/react version:
  • @faustjs/next version: 0.15.6
  • WordPress version: 6.0

Steps To Reproduce

  1. Create sitemap middleware based on docs
  2. Deploy to Atlas platform
  3. Visit sitemap url

Link to code example: https://github.com/JEverhart383/atlas-demo-app/blob/main/src/pages/_middleware.ts

The current behavior

URL in sitemap entries is rewritten to localhost:8080 when proxied, b/c value of req.url.origin is localhost:8080 on Atlas platform: Example logs of console.log(req:NextRequest)

06/08/2022 01:30:55 PM UTC NextRequestHint [Request] { 06/08/2022 01:30:55 PM UTC sourcePage: '/_middleware', 06/08/2022 01:30:55 PM UTC [Symbol(internal body)]: { bodyInit: null, disturbed: false }, 06/08/2022 01:30:55 PM UTC [Symbol(internal request)]: { 06/08/2022 01:30:55 PM UTC credentials: 'same-origin', 06/08/2022 01:30:55 PM UTC headers: BaseHeaders [Headers] { [Symbol(map)]: [Object] }, 06/08/2022 01:30:55 PM UTC method: 'GET', 06/08/2022 01:30:55 PM UTC referrer: 'about:client', 06/08/2022 01:30:55 PM UTC redirect: 'follow', 06/08/2022 01:30:55 PM UTC url: NextURL { [Symbol(NextURLInternal)]: [Object] } 06/08/2022 01:30:55 PM UTC [Symbol(internal request)]: { 06/08/2022 01:30:55 PM UTC cookieParser: [Function: cookieParser], 06/08/2022 01:30:55 PM UTC geo: {}, 06/08/2022 01:30:55 PM UTC URL { 06/08/2022 01:30:55 PM UTC href: 'http://localhost:8080/sitemap_index.xml', 06/08/2022 01:30:55 PM UTC origin: 'http://localhost:8080', 06/08/2022 01:30:55 PM UTC protocol: 'http:', 06/08/2022 01:30:55 PM UTC username: '', 06/08/2022 01:30:55 PM UTC password: '', 06/08/2022 01:30:55 PM UTC host: 'localhost:8080', 06/08/2022 01:30:55 PM UTC hostname: 'localhost', 06/08/2022 01:30:55 PM UTC port: '8080', 06/08/2022 01:30:55 PM UTC pathname: '/sitemap_index.xml', 06/08/2022 01:30:55 PM UTC search: '', 06/08/2022 01:30:55 PM UTC searchParams: URLSearchParams {}, 06/08/2022 01:30:55 PM UTC hash: ''

The expected behavior

Expect sitemap entries to contain actual FE url

JEverhart383 avatar Jun 08 '22 14:06 JEverhart383