Skip to content

Instantly share code, notes, and snippets.

View domosedov's full-sized avatar
🏠
Working from home

Aleksandr Grigorii domosedov

🏠
Working from home
View GitHub Profile
@domosedov
domosedov / example.api.ts
Created December 8, 2022 12:10 — 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" });