mirror of
https://github.com/better-auth/better-auth.git
synced 2026-07-30 17:12:35 -05:00
fix: access of undefined in runtime that does have great support of instanceof (#1838)
* fix: access of undefined in open-nextjs hosted runtime - This change follows the "duck typing" principle which is often more robust than strict instance checking, especially in complex JavaScript environments where objects might come from different contexts or realms. - Fixes issue where in an opennext hosted runtime, instanceof usage is not sufficent. * feat: use in operator for better reliabiltiy across runtimes * fix: linting issue
This commit is contained in:
@@ -249,7 +249,7 @@ export const getSessionCookie = (
|
||||
config.cookiePrefix = `${config.cookiePrefix}.`;
|
||||
}
|
||||
}
|
||||
const headers = request instanceof Headers ? request : request.headers;
|
||||
const headers = "headers" in request ? request.headers : request;
|
||||
const req = request instanceof Request ? request : undefined;
|
||||
const url = getBaseURL(req?.url, config?.path, req);
|
||||
const cookies = headers.get("cookie");
|
||||
|
||||
@@ -24,7 +24,7 @@ export function getIp(
|
||||
"forwarded-for",
|
||||
"forwarded",
|
||||
];
|
||||
const headers = req instanceof Request ? req.headers : req;
|
||||
const headers = "headers" in req ? req.headers : req;
|
||||
for (const key of keys) {
|
||||
const value = headers.get(key);
|
||||
if (typeof value === "string") {
|
||||
|
||||
Reference in New Issue
Block a user