Skip to content

Instantly share code, notes, and snippets.

View dovranJorayev's full-sized avatar

dovran dovranJorayev

View GitHub Profile
@dovranJorayev
dovranJorayev / example.api.ts
Created June 27, 2023 06:50 — forked from epicbytes/example.api.ts
NextJS Authorization Files
/*** function that used as middleware ***/
accessToken: async (name) => {
if (typeof document === "undefined") return "";
let token = document.cookie
.split(";")
.filter((cookie) => cookie.startsWith("token"))[0];
if (!token) {
const response = await fetch("/api/refresh", { method: "POST" });