try clerk token instead
This commit is contained in:
@@ -17,7 +17,7 @@ import superjson from 'superjson';
|
|||||||
import { OpenpanelProvider } from '@openpanel/nextjs';
|
import { OpenpanelProvider } from '@openpanel/nextjs';
|
||||||
|
|
||||||
function AllProviders({ children }: { children: React.ReactNode }) {
|
function AllProviders({ children }: { children: React.ReactNode }) {
|
||||||
const { userId } = useAuth();
|
const { userId, getToken } = useAuth();
|
||||||
const [queryClient] = useState(
|
const [queryClient] = useState(
|
||||||
() =>
|
() =>
|
||||||
new QueryClient({
|
new QueryClient({
|
||||||
@@ -36,14 +36,22 @@ function AllProviders({ children }: { children: React.ReactNode }) {
|
|||||||
links: [
|
links: [
|
||||||
httpLink({
|
httpLink({
|
||||||
url: `${process.env.NEXT_PUBLIC_API_URL}/trpc`,
|
url: `${process.env.NEXT_PUBLIC_API_URL}/trpc`,
|
||||||
fetch(url, options) {
|
async headers() {
|
||||||
// Send cookies
|
const token = await getToken();
|
||||||
return fetch(url, {
|
if (token) {
|
||||||
...options,
|
return {
|
||||||
credentials: 'include',
|
Authorization: `Bearer ${token}`,
|
||||||
mode: 'cors',
|
};
|
||||||
});
|
}
|
||||||
|
return {};
|
||||||
},
|
},
|
||||||
|
// fetch(url, options) {
|
||||||
|
// return fetch(url, {
|
||||||
|
// ...options,
|
||||||
|
// credentials: 'include',
|
||||||
|
// mode: 'cors',
|
||||||
|
// });
|
||||||
|
// },
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user