steven-tey / novel

Notion-style WYSIWYG editor with AI-powered autocompletion.
https://novel.sh
Apache License 2.0
13.23k stars 1.08k forks source link

How to handle auth? #200

Closed emil14 closed 9 months ago

emil14 commented 1 year ago

Here we can see than Novel calls fetch without ability to insert custom headers. Same goes for 'api/generate' logic. How one must implement auth?

tunogya commented 1 year ago

I use Auth0 in NextJS, so i can do this at Edge environment:

import { getSession } from "@auth0/nextjs-auth0/edge";

export const runtime = "edge";

// api/generate code here
export async function POST(req: Request): Promise<Response> {
    const { user } = await getSession();

    ...

}
andrewdoro commented 9 months ago

This is not really related to Novel, I've also disabled the AI feature for now. After I finish my work it would be opt-in and fully customizable.