ReeceM / prismic-sitemap

A sitemap generator for next.js websites based on the pages in your Prismic backed Next.js application. Minimal Configuration
MIT License
12 stars 3 forks source link

UnhandledPromiseRejectionWarning: Error: Unexpected status code [401] on URL #6

Closed amala-james-cko closed 3 years ago

amala-james-cko commented 3 years ago

Describe the Bug When trying to build the application after adding sitemap config in next.config.js, it's throwing the following error.

(node:50640) UnhandledPromiseRejectionWarning: Error: Unexpected status code [401] on URL https://website.url.here.cdn.prismic.io/api/v2

It looks like the error is happening since the token is not passed with the prismic API endpoint. Is there a way to pass it or is this because of some other issue?

ReeceM commented 3 years ago

Hi @amala-james-cko, thank you for raising this bug. 👍

Right now there isn't a way to pass the API token as I hadn't implemented it in the package.

I will have a look at it to add this in as it was overlooked about the private Prismic repository options

ReeceM commented 3 years ago

There is the one option where you can set the repo if you are able to that it uses no API token when you are queuing documents that have been released already. This is only a temp solution while I make the patch though if you need to be generating the sitemap right now.

So the sitemap generator would only be able to fetch documents that have been published, but not unpublished ones. But

amala-james-cko commented 3 years ago

The option where we can set the repo, It works only if the APIs are public right? If the API are private and requires access token does it work?

ReeceM commented 3 years ago

The option where we can set the repo, It works only if the APIs are public right? If the API are private and requires access token does it work?

At version 0.1.1 it only works if they are public.

I will be publishing version 0.2.0 in a few minutes that will allow you to pass the token into the sitemap generator to fetch it from repos. that need a token to access it.

ReeceM commented 3 years ago

@amala-james-cko please feel free to open up the issue again if it still persists 👍