Skip to content

Commit

Permalink
fix: supress auth warnings, see supabase/auth-js#888
Browse files Browse the repository at this point in the history
  • Loading branch information
krystlc committed Nov 29, 2024
1 parent a70014f commit 618e7ed
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,40 @@ import { defineConfig } from 'vitest/config';
import { sveltekit } from '@sveltejs/kit/vite';

export default defineConfig({
plugins: [sveltekit()],
plugins: [sveltekit(), myErrorFilterPlugin()],

test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}
});

// myErrorFilterPlugin.ts
import type { Plugin } from 'vite';

export function myErrorFilterPlugin(): Plugin {
return {
name: 'error-filter-plugin',
configureServer() {
const filterMessage =
'Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and many not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server.';

// Intercept console.warn
const originalWarn = console.warn;
console.warn = (...args: unknown[]) => {
if (args[0] && typeof args[0] === 'string' && args[0].includes(filterMessage)) {
return;
}
originalWarn(...args);
};

// Intercept console.log
const originalLog = console.log;
console.log = (...args: unknown[]) => {
if (args[0] && typeof args[0] === 'string' && args[0].includes(filterMessage)) {
return;
}
originalLog(...args);
};
}
};
}

0 comments on commit 618e7ed

Please sign in to comment.