Bug: Sitemap URLs rewrite to locahost:8080 on Atlas
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/coreversion: 0.15.6@faustjs/reactversion:@faustjs/nextversion: 0.15.6- WordPress version: 6.0
Steps To Reproduce
- Create sitemap middleware based on docs
- Deploy to Atlas platform
- 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