dylanebert commited on
Commit
2698c57
·
1 Parent(s): 5261a1c

Revert overly strict token validation in frontend

Browse files

- Allow null/invalid tokens to be passed to backend
- Backend now handles invalid tokens gracefully
- Maintains original OAuth flow behavior
- Users can vote even with expired tokens in localStorage

src/routes/Vote.svelte CHANGED
@@ -45,18 +45,12 @@
45
  try {
46
  const url = "/api/fetchScenes";
47
  const token = localStorage.getItem("access_token");
48
- const headers = {
49
- "Cache-Control": "no-cache",
50
- };
51
-
52
- // Only add Authorization header if we have a valid token
53
- if (token) {
54
- headers.Authorization = `Bearer ${token}`;
55
- }
56
-
57
  const response = await fetch(url, {
58
  method: "GET",
59
- headers,
 
 
 
60
  });
61
  const result = await response.json();
62
  if (result.input) {
 
45
  try {
46
  const url = "/api/fetchScenes";
47
  const token = localStorage.getItem("access_token");
 
 
 
 
 
 
 
 
 
48
  const response = await fetch(url, {
49
  method: "GET",
50
+ headers: {
51
+ "Cache-Control": "no-cache",
52
+ Authorization: `Bearer ${token}`,
53
+ },
54
  });
55
  const result = await response.json();
56
  if (result.input) {
src/routes/api/fetchScenes/+server.ts CHANGED
@@ -5,11 +5,7 @@ export const GET: RequestHandler = async ({ request }) => {
5
  const authHeader = request.headers.get("authorization");
6
  let accessToken = null;
7
  if (authHeader && authHeader.startsWith("Bearer ")) {
8
- const token = authHeader.substring("Bearer ".length);
9
- // Don't use token if it's null, undefined, or empty string
10
- if (token && token !== "null" && token !== "undefined") {
11
- accessToken = token;
12
- }
13
  }
14
 
15
  const url = accessToken
 
5
  const authHeader = request.headers.get("authorization");
6
  let accessToken = null;
7
  if (authHeader && authHeader.startsWith("Bearer ")) {
8
+ accessToken = authHeader.substring("Bearer ".length);
 
 
 
 
9
  }
10
 
11
  const url = accessToken