Skip to content

Next.js example is not working #1295

@valstu

Description

@valstu

Tried to follow the Next.js guide on your website https://www.rivet.dev/docs/actors/quickstart/next-js/ but ended up having problems. Rivetkit tries to make PUT request to the defined endpoint /api/rivet/[...all]/route.ts

Image

Although when you take a look at the implementation of toNextHandler. It does not export any PUT-method. This seemed quite simple function so I tried guessing and implemented it myself to the route.ts like this:

import { registry } from "@/rivet/registry";
import { Registry, RunConfigInput } from "rivetkit";

const toNextHandler = (
  registry: Registry<any>,
  inputConfig: RunConfigInput = {}
) => {
  // Don't run server locally since we're using the fetch handler directly
  inputConfig.disableServer = true;
  inputConfig.basePath = "/api/rivet";

  const { fetch } = registry.start(inputConfig);

  return {
    GET: fetch,
    POST: fetch,
    PATCH: fetch,
    PUT: fetch,
    HEAD: fetch,
    OPTIONS: fetch,
  };
};

// Export the Next.js handler for the API routes
export const { GET, POST, HEAD, PATCH, OPTIONS, PUT } = toNextHandler(registry);

But then I started to get following errors:

level=WARN msg="internal error" error="Offset is outside the bounds of the DataView" stack="RangeError: Offset is outside the bounds of the DataView\n    at DataView.prototype.getUint32 (<anonymous>)\n ...

I used the latest version of rivetkit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions