I’m using auth0-nextjs. It is interacting with a Flask API. I have implemented API routes on my NextJS App using the concept below:
import { withApiAuthRequired, getAccessToken } from "@auth0/nextjs-auth0";
export default withApiAuthRequired(async function publications(req, res) {
try {
const { accessToken } = await getAccessToken(req, res, {});
// This is a contrived example, normally your external API would exist on another domain.
const response = await fetch("http://127.0.0.1:5000/data", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
const publications = await response.json();
res.status(response.status || 200).json(publications);
} catch (error) {
res.status(error.status || 500).json({
code: error.code,
error: error.message,
});
}
});
Now, I want to use getStaticProps
to display stuff on a page. How would I do that using the auth0-nextjs
SDK? Sorry if this is a super simple answer, I’m new to React frameworks and auth0