Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

try clerk token instead

Carl-Gerhard Lindesvärdc63c83e86669
diff --git a/apps/dashboard/src/app/providers.tsx b/apps/dashboard/src/app/providers.tsx
index 27115a125..fd223d6a4 100644
--- a/apps/dashboard/src/app/providers.tsx
+++ b/apps/dashboard/src/app/providers.tsx
@@ -17,7 +17,7 @@ import superjson from 'superjson';
import { OpenpanelProvider } from '@openpanel/nextjs';
function AllProviders({ children }: { children: React.ReactNode }) {
- const { userId } = useAuth();
+ const { userId, getToken } = useAuth();
const [queryClient] = useState(
() =>
new QueryClient({
@@ -36,14 +36,22 @@ function AllProviders({ children }: { children: React.ReactNode }) {
links: [
httpLink({
url: `${process.env.NEXT_PUBLIC_API_URL}/trpc`,
- fetch(url, options) {
- // Send cookies
- return fetch(url, {
- ...options,
- credentials: 'include',
- mode: 'cors',
- });
+ async headers() {
+ const token = await getToken();
+ if (token) {
+ return {
+ Authorization: `Bearer ${token}`,
+ };
+ }
+ return {};
},
+ // fetch(url, options) {
+ // return fetch(url, {
+ // ...options,
+ // credentials: 'include',
+ // mode: 'cors',
+ // });
+ // },
}),
],
})