-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: vercel middleware stripping auth headers #66
base: staging
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
const pathname = req.nextUrl.pathname; | ||
// const sessionToken = | ||
// req.cookies.get(SESSION_KEY)?.value || req.headers.get("Authorization")?.split(" ")[1]; | ||
|
||
// if (protectedRoutes.some((path) => pathname.startsWith(path))) { | ||
// if (!sessionToken) { | ||
// return appError({ status: 401, error: "No session provided" }); | ||
// } | ||
|
||
// const { | ||
// data: { user_id }, | ||
// } = await axiosInstance.post("/api/utils/decode", { session: sessionToken }); | ||
|
||
// if (!user_id) { | ||
// return appError({ status: 401, error: "Invalid session" }); | ||
// } | ||
|
||
// const res = NextResponse.next(); | ||
// res.headers.set(HEADER_DATA_KEY, user_id); | ||
// return res; | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superfluous
const status = error?.response?.status; | ||
|
||
// if (status === 401) { | ||
// // const refreshToken = await getCookie(JWT_KEY); | ||
|
||
// // if (!refreshToken) { | ||
// // return Promise.reject(error); | ||
// // } | ||
|
||
// // try { | ||
// // const { access, refresh } = await AuthService.refreshJwt({ | ||
// // refresh: refreshToken, | ||
// // }); | ||
|
||
// // if (access && refresh) { | ||
// // axiosPrivate.defaults.headers.common["Authorization"] = "Bearer " + access; | ||
// // await setCookie(JWT_KEY, refresh); | ||
// // } | ||
// // } catch (error) { | ||
// // if (isAxiosError(error)) { | ||
// // if (error.response?.status === 401) { | ||
// // await deleteCookie(JWT_KEY); | ||
// // } | ||
// // } | ||
// // } | ||
|
||
// return axiosPrivate.request(error?.config); | ||
// } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superfluous
const cache: { | ||
user: User | null; | ||
} = { | ||
user: null, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superfluous
Attempting fix from: https://stackoverflow.com/questions/70996838/vercel-production-branch-is-stripping-authorization-header-on-post-to-serverless