Skip to content

handleSitemapRequests will not work with next.js ^12.2.0 #1104

Answered by theodesp
priard asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @priard. We've recently added a helper that overcomes this issue with next.js. Unfortunately we haven't documented this yet but its easy to use it.

Here is how to enable this:

  1. Create a sitemap.xml.ts in the pages directory:

  2. Create a page that handles the sitemap request:

import {getSitemapProps} from '@faustjs/next/server';
export default function Page() {
  return null;
}

export const getServerSideProps = async (ctx) => {
  return getSitemapProps(ctx, {
    frontendUrl: 'http://localhost:3000', // or your public frontend URL
    wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
    sitemapIndexPath: '/wp-sitemap.xml' // path in WordPress that handles sitemaps
  });
}

Visit your …

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@roeean
Comment options

Answer selected by theodesp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #912 on October 21, 2022 10:20.