you can import cookie like this
import { cookies } from "next/headers";
and after that you should use set method from cookie which you have imported from next/headers like this :
cookies().set('name of token', yourtoken , { httpOnly: true })
and then return your token