Hey there,
I have a pretty weird Error, this error started, after creating a new Page Type. So I removed the Page Type again in the Sliceeditor and pushed it to the Server.
I also removed all the Code I created (just went one commit back)...
Now I get this Error:
PrismicError: An invalid API response was returned
at Client.fetch (webpack-internal:///(rsc)/./node_modules/@prismicio/client/dist/createClient.js:1163:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.getFirst (webpack-internal:///(rsc)/./node_modules/@prismicio/client/dist/createClient.js:277:24)
at async Client.getSingle (webpack-internal:///(rsc)/./node_modules/@prismicio/client/dist/createClient.js:533:16)
at async Module.generateMetadata (webpack-internal:///(rsc)/./src/app/page.tsx:29:18) {
url: 'https://myproject.cdn.prismic.io/api/v2/documents/search?q=%5B%5Bat%28document.type%2C+%22home%22%29%5D%5D&pageSize=1&ref=ZbJl-xEAAB8A-iZe&routes=%5B%7B%22type%22%3A%22home%22%2C%22path%22%3A%22%2F%22%7D%2C%7B%22type%22%3A%22page%22%2C%22path%22%3A%22%2F%3Auid%22%7D%2C%7B%22type%22%3A%22neuigkeiten_post%22%2C%22path%22%3A%22%2Fneuigkeiten%2F%3Auid%22%7D%2C%7B%22type%22%3A%22neuigkeiten%22%2C%22path%22%3A%22%2Fneuigkeiten%2Fpage.tsx%22%7D%5D',
response: undefined
}
I use Next Js:
my Configuration Files are all right.
I tried:
- Updating all Packeges
- Restarting my PC
- Updated Node js
- Connecting my Project again with the Prismic project (npx @slicemachine/init@latest --repository my-project)
Here are the other files:
{
"repositoryName": "my-project",
"adapter": "@slicemachine/adapter-next",
"libraries": ["./src/slices"],
"localSliceSimulatorURL": "http://localhost:3000/slice-simulator"
}
import * as prismic from "@prismicio/client";
import * as prismicNext from "@prismicio/next";
import config from "../slicemachine.config.json";
/**
* The project's Prismic repository name.
*/
export const repositoryName =
process.env.NEXT_PUBLIC_PRISMIC_ENVIRONMENT || config.repositoryName;
/**
* A list of Route Resolver objects that define how a document's `url` field is resolved.
*
* {@link https://prismic.io/docs/route-resolver#route-resolver}
*/
// TODO: Update the routes array to match your project's route structure.
const routes: prismic.ClientConfig["routes"] = [
{
type: "home",
path: "/",
},
{
type: "page",
path: "/:uid",
},
{
type: "neuigkeiten_post",
path: "/neuigkeiten/:uid",
},
{
type: "neuigkeiten",
path: "/neuigkeiten/page.tsx",
},
];
/**
* Creates a Prismic client for the project's repository. The client is used to
* query content from the Prismic API.
*
* @param config - Configuration for the Prismic client.
*/
export const createClient = (config: prismicNext.CreateClientConfig = {}) => {
const client = prismic.createClient(repositoryName, {
routes,
fetchOptions:
process.env.NODE_ENV === "production"
? { next: { tags: ["prismic"] }, cache: "force-cache" }
: { next: { revalidate: 5 } },
...config,
});
prismicNext.enableAutoPreviews({
client,
previewData: config.previewData,
req: config.req,
});
return client;
};