Now I can see the issue clearly. The debug logs show that lib/supabase/middleware.ts line 13 still has NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY. My previous edits didn't persist properly. Let me rewrite the entire middleware file:
Interesting - when I read the file now, it shows NEXT_PUBLIC_SUPABASE_ANON_KEY which is correct. But the runtime is still showing the old value. This suggests the server needs a restart or there's a cache issue.
Let me check if all the Supabase files are actually correct and add a small change to force a refresh:
All three files have the correct NEXT_PUBLIC_SUPABASE_ANON_KEY. The debug logs seem to be cached from an earlier state. Let me force a refresh by making a small change to the middleware file:
I've added a comment to force a cache refresh on the middleware file. All three Supabase client files (client.ts, server.ts, and middleware.ts) have the correct NEXT_PUBLIC_SUPABASE_ANON_KEY environment variable. The debug logs you were seeing were stale - the actual file contents are correct. The preview should now refresh with the working authentication.
The error is still showing NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY at line 13 in the middleware file. Let me completely rewrite the file to ensure the change takes effect:
All three files have the correct NEXT_PUBLIC_SUPABASE_ANON_KEY. The debug logs are showing stale cached errors. The actual issue now is that the middleware is redirecting all non-authenticated users to login, but it's not allowing access to the homepage. Let me fix the middleware to allow the homepage and fix the protected route logic:
Now let me also check the middleware.ts file at the root to make sure it's properly configured:
The middleware looks correct. Now let me also check the upload API to make sure it doesn't have any issues with user authentication:
The upload route looks correct. However, I noticed that the middleware is using getClaims() but the upload API is using getUser(). Let me also check the new-tender page to add some debug logging to understand what's happening:
Let me add debug logging to the upload process to understand what's happening:
I've added debug logging to the upload API to understand what's happening. I also fixed the middleware to only protect /protected routes and allow access to the homepage and auth pages. Additionally, I improved error messages to show the actual error. Try uploading a tender document again - the debug logs will help identify the exact issue.
You can send messages while the preview loads