Skip to content

Commit

Permalink
remove unused isSecureEnvironment function
Browse files Browse the repository at this point in the history
  • Loading branch information
dijonmusters committed Aug 31, 2023
1 parent e12678f commit bb251df
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
10 changes: 1 addition & 9 deletions packages/ssr/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
export * from './createBrowserClient';
export * from './createServerClient';
export * from './types';

export {
parseCookies,
serializeCookie,
parseSupabaseCookie,
stringifySupabaseSession,
isBrowser,
DEFAULT_COOKIE_OPTIONS
} from './utils';
export * from './utils';
18 changes: 0 additions & 18 deletions packages/ssr/src/utils/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@ import { base64url } from 'jose';

export { parse as parseCookies, serialize as serializeCookie };

/**
* Based on the environment and the request we know if a secure cookie can be set.
*/
export function isSecureEnvironment(headerHost?: string | string[]) {
if (!headerHost) {
throw new Error('The "host" request header is not available');
}

const headerHostStr = Array.isArray(headerHost) ? headerHost[0] : headerHost;

const host = (headerHostStr.indexOf(':') > -1 && headerHostStr.split(':')[0]) || headerHostStr;
if (['localhost', '127.0.0.1'].indexOf(host) > -1 || host.endsWith('.local')) {
return false;
}

return true;
}

export function parseSupabaseCookie(str: string | null | undefined): Partial<Session> | null {
if (!str) {
return null;
Expand Down

0 comments on commit bb251df

Please sign in to comment.