mirror of
https://github.com/D4M13N-D3V/neroshitron.git
synced 2025-03-14 10:05:04 +00:00
fix: navbar highlight
This commit is contained in:
parent
23137d4e04
commit
21fa376190
12
app/middleware/url-header.tsx
Normal file
12
app/middleware/url-header.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { NextRequest, NextResponse } from 'next/server'
|
||||||
|
|
||||||
|
export function middleware(req:NextRequest, res:NextResponse) {
|
||||||
|
const requestHeaders = new Headers(req.headers)
|
||||||
|
requestHeaders.set('x-path', req.nextUrl.pathname)
|
||||||
|
|
||||||
|
return NextResponse.next({
|
||||||
|
request: {
|
||||||
|
headers: requestHeaders
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
|
import { createClient } from "@/utils/supabase/server";
|
||||||
"use client";
|
|
||||||
import { createClient } from "@/utils/supabase/client";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { redirect, useRouter } from "next/navigation";
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { useRouter } from 'next/router';
|
import { headers } from "next/headers";
|
||||||
|
|
||||||
|
|
||||||
export default async function AuthButton() {
|
export default async function AuthButton() {
|
||||||
@ -14,18 +13,19 @@ export default async function AuthButton() {
|
|||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getUser();
|
||||||
|
|
||||||
const signOut = async () => {
|
const signOut = async () => {
|
||||||
|
"use server";
|
||||||
|
|
||||||
const supabase = createClient();
|
const supabase = createClient();
|
||||||
await supabase.auth.signOut();
|
await supabase.auth.signOut();
|
||||||
window.location.href = "/gallery";
|
return redirect("/login");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
const router = useRouter();
|
const heads = headers()
|
||||||
const currentPage = router.pathname;
|
const currentPage = heads.get('x-path')
|
||||||
if(user){
|
if(user){
|
||||||
let email = user.email;
|
let email = user.email;
|
||||||
if(email != null){
|
if(email != null){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user