Skip to main content
Last updated on
Advanced — 0.0.x primitives

You don't need this page for a normal integration. Use the quickstarts and createMythos() instead. These low-level functions remain exported for custom setups.

Vercel serverless

Deploy Mythos SDK routes on Vercel with serverless functions and rewrites.

info

Also see: Next.js quickstart for App Router · Express quickstart for traditional servers

One handler per route​

Place handlers under api/:

api/mythos-handshake.js:

javascript
const { handshakeRoute } = require('@mythos-work/sdk');
const router = handshakeRoute();
// Export the handshake GET handler from the router stack
module.exports = (req, res) => router(req, res, () => res.status(404).end());

For a cleaner setup, use the Next.js App Router quickstart instead of raw api/ files.

api/mythos-session.js:

javascript
const { requireLaunchToken } = require('@mythos-work/sdk');
const middleware = requireLaunchToken();
module.exports = (req, res) =>
middleware(req, res, () => res.status(200).json({ ok: true, session: req.mythos }));

Handshake rewrite​

Vercel serves api/ routes at /api/* by default. Mythos expects the handshake at /.well-known/mythos-handshake. Add a rewrite in vercel.json:

json
{
"rewrites": [
{
"source": "/.well-known/mythos-handshake",
"destination": "/api/mythos-handshake"
}
]
}

Without this rewrite, the publish gate gets 404 — Mythos will not accept /api/mythos-handshake as a substitute path.

Multiple entry points​

warning

A common failure mode: Mythos routes wired in backend/main.py for local dev but missing from api/index.py (or Vercel api/). Production returns 404 while local works. Wire Mythos on every deploy entry point.

Environment variables​

Set in Vercel project settings:

  • MYTHOS_LISTING_ID
  • MYTHOS_API_URL (if not using production API)

Node runtime​

Ensure serverless functions use Node.js runtime, not Edge — JWKS verification requires Node fetch and crypto.

Next steps​