Slices API unauthorized on NextJS

Here's my dependency list:

{
  "name": "edit-elements",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "storybook": "start-storybook -p 8888",
    "build-storybook": "build-storybook",
    "slicemachine": "start-slicemachine --port 9999"
  },
  "dependencies": {
    "@emotion/react": "^11.4.0",
    "@emotion/styled": "^11.3.0",
    "@material-ui/core": "^5.0.0-alpha.31",
    "@material-ui/icons": "^4.11.2",
    "@material-ui/lab": "^4.0.0-alpha.58",
    "@prismicio/client": "^4.0.0",
    "clsx": "^1.1.1",
    "essential-slices": "^1.0.4",
    "firebase": "^8.2.1",
    "firebase-admin": "^9.4.2",
    "firebaseui": "^4.7.1",
    "framer-motion": "^3.1.1",
    "imagemin-mozjpeg": "^9.0.0",
    "imagemin-optipng": "^8.0.0",
    "imagemin-svgo": "^9.0.0",
    "next": "^10.2.1",
    "next-compose-plugins": "^2.2.1",
    "next-optimized-images": "^2.6.2",
    "next-slicezone": "^0.0.15",
    "next-svgr": "^0.0.2",
    "next-transpile-modules": "^6.4.1",
    "prismic-dom": "^2.2.5",
    "prismic-javascript": "^3.0.2",
    "prismic-reactjs": "^1.3.3",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "responsive-loader": "^2.0.0",
    "sass": "^1.32.4",
    "slice-machine-ui": "^0.0.45",
    "styled-components": "^5.2.1",
    "theme-ui": "^0.7.3",
    "webp-loader": "^0.6.0"
  },
  "devDependencies": {
    "babel-plugin-react-require": "^3.1.3"
  }
}

Here's my sm-resolver:

module.exports = {
  apiEndpoint: 'https://edit-elements.cdn.prismic.io/api/v2',
  repoName: "edit-elements",
  linkResolver: function(doc) {
      if (doc.isBroken) {
          return '/not-found';
      }
      if (doc.type === 'home') {
          return '/';
      }
      if (doc.type === 'page') {
          return '/page/' + doc.uid
      }
      return '/'
  }
}`

Here's my sm.json file:

{
  "apiEndpoint": "https://api.slicemachine.dev/2020-10-27",
  "libraries": [
    "@/slices",
    "essential-slices"
  ],
  "storybook": "http://localhost:8888",
  "_latest": "0.0.45"
}

I can't just wipe everything, because this install has setup already on it. I just wanted to integrate prismic/storybook into my existing NextJS project. Please advise. Thanks!

I ended up figure out that the apiEndpoint that is created is not correct. Updaing the apiEndpoint in my sm.json file fixed everything.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.