Legacy Type Builder - None of the API tools work properly

Describe your question/issue in detail

First of all: I am using the Legacy Type Builder because I am making heavy use of declarative shadow dom which works nicely with express.js (using handlebars templates). This way, as a developer, I am not trapped by any weird framework quirks.

That being said:

  • The Preview Toolbar does not appear in preview, despite the code being propery entered in the html head.
  • I've set up client.enableAutoPreviewsFromReq in the /preview route, but it has no effect whatsoever. In particular, it does not set the session cookie with the proper draft token.

Impacted feature

Previews with Legacy Type Builder

What steps have you taken to resolve this issue already?

Setting cookies programmatically.

Errors

No errors, the API is simply not working as described.

Your Role

Developer

Hosting provider

Self hosting

Package.json file


{
  "name": "www",
  "type": "module",
  "version": "0.0.1",
  "scripts": {
    "dev": "NODE_ENV=development node server.js",
    "serve": "NODE_ENV=production node server.js",
    "watch-styleguide": "chokidar 'site/**/*.*' -c 'yarn build-styleguide'",
    "build-styleguide": "NODE_ENV=production STYLE_ROOT=public/resources node node_modules/mk-living-style",
    "generate-route-docs": "node scripts/generate-route-docs.js",
    "_comment": "The following scripts are for the font copying and CSS generation",
    "//copy-fonts": "node lib/deploy/copy-fonts.js",
    "//postinstall": "npm run copy-fonts"
  },
  "prettier": {
    "singleQuote": true,
    "printWidth": 80,
    "overrides": [
      {
        "files": [
          "**/*.css",
          "**/*.scss",
          "**/*.sass",
          "**/*.html",
          "**/*.hbs",
          "**/*.handlebars"
        ],
        "options": {
          "singleQuote": false
        }
      }
    ]
  },
  "devDependencies": {
    "mk-living-style": "https://github.com/mkastner/mk-living-style.git",
    "supertest": "^7.0.0"
  },
  "dependencies": {
    "@fontsource-variable/inter": "^5.0.20",
    "@fontsource/inter": "^5.0.20",
    "@fontsource/noto-sans-linear-a": "^5.0.20",
    "@prismicio/client": "^7.8.0",
    "@prismicio/helpers": "^2.3.9",
    "chokidar": "^3.6.0",
    "cookie-parser": "^1.4.6",
    "express": "^4.19.2",
    "express-handlebars": "^8.0.1",
    "quick-lru": "^7.0.0",
    "tracer": "^1.3.0",
    "ws": "^8.18.0"
  }
}

Steps to reproduce

Set up a LegacyType project with express.js

Also, in this part of your documentation

it says: "In Settings > Previews, you will find a script like this: [the preview script]"

Guess what, all that appears in "Settings > Previews" is a field to change the repository label. There is no script tag as promised by the documentation.

Nothing works as promised by the documentation.

My experience with prismic.io so far has been a total nightmare.

Hi Mike,

Sorry to see you're running into problems.

Let's go through this bit by bit. For the previews script you should see the tab and sccript like this, is this not the case?

When you say you're self-hosting your project, who is your provider service? Heroku? Netlify?

Can you share the code for your preview route with me?

Can you also share the code of your 404 page?

What browser are you test in?

Thanks.