hmm
This commit is contained in:
@@ -10,17 +10,19 @@ export async function middleware(req: NextRequest) {
|
||||
}
|
||||
|
||||
try {
|
||||
// Use SERVER_API_URL which should be set to a working URL in the .env files
|
||||
const apiUrl = process.env.SERVER_API_URL || 'https://internal-api.inboxi.ng/api';
|
||||
console.log(`Using API URL for authentication: ${apiUrl}/auth/me`);
|
||||
// Use our internal API route that handles the auth check server-side
|
||||
// This avoids SSL issues as it's a same-origin request
|
||||
const origin = req.nextUrl.origin;
|
||||
const authCheckUrl = `${origin}/api/auth/check`;
|
||||
|
||||
const res = await fetch(`${apiUrl}/auth/me`, {
|
||||
console.log(`Using internal auth check URL: ${authCheckUrl}`);
|
||||
|
||||
const res = await fetch(authCheckUrl, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
// No Node.js-specific options as middleware runs in Edge Runtime
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user