Yvonne Priscilla commited on
Commit
8f32a26
·
1 Parent(s): d635176

form data

Browse files
src/app/api/auth/logout/route.ts CHANGED
@@ -12,6 +12,7 @@ export async function POST(request: NextRequest) {
12
  try {
13
  const cookieStore = await cookies();
14
  cookieStore.delete("auth_token");
 
15
 
16
  return NextResponse.json(
17
  { message: "Logged out successfully" },
 
12
  try {
13
  const cookieStore = await cookies();
14
  cookieStore.delete("auth_token");
15
+ localStorage.removeItem("token")
16
 
17
  return NextResponse.json(
18
  { message: "Logged out successfully" },
src/lib/auth-context.tsx CHANGED
@@ -44,15 +44,15 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
44
  async (username: string, password: string) => {
45
  setIsLoading(true);
46
 
 
 
 
 
47
  try {
48
- const origin = new URL(window?.location?.href || "").origin;
49
- const response = await fetch(`${origin}/api/auth/login`, {
50
  method: "POST",
51
  credentials: "include",
52
- headers: {
53
- "Content-Type": "application/json",
54
- },
55
- body: JSON.stringify({ username, password }),
56
  });
57
 
58
  if (!response.ok) {
 
44
  async (username: string, password: string) => {
45
  setIsLoading(true);
46
 
47
+ const formData = new FormData();
48
+ formData.append('username', username);
49
+ formData.append('password', password);
50
+
51
  try {
52
+ const response = await fetch("https://byteriot-candidateexplorer.hf.space/CandidateExplorer/admin/login", {
 
53
  method: "POST",
54
  credentials: "include",
55
+ body: formData,
 
 
 
56
  });
57
 
58
  if (!response.ok) {