mentorenwahl/docker/frontend/pages/_app.tsx

28 lines
719 B
TypeScript
Raw Normal View History

2022-01-29 15:40:39 +00:00
import type { AppProps } from "next/app";
2022-02-02 14:38:36 +00:00
import { ApolloProvider, ApolloClient, InMemoryCache } from "@apollo/client";
2022-02-02 20:54:14 +00:00
import Cookies from "js-cookie";
2022-01-29 15:40:39 +00:00
2022-02-02 14:38:36 +00:00
import MainLayout from "../layouts/main";
2022-01-29 15:40:39 +00:00
import "../styles/globals.css";
2022-02-02 20:54:14 +00:00
import * as cookieNames from "../lib/cookieNames";
const token = Cookies.get(cookieNames.TOKEN);
2022-01-29 15:40:39 +00:00
2022-02-02 14:38:36 +00:00
const client = new ApolloClient({
uri: "/graphql",
cache: new InMemoryCache(),
2022-02-02 20:54:14 +00:00
headers: token ? { authorization: `Bearer ${token}` } : {},
2022-02-02 14:38:36 +00:00
});
function MyApp({ Component, pageProps }: AppProps): JSX.Element {
return (
<ApolloProvider client={client}>
<MainLayout>
<Component {...pageProps} />
</MainLayout>
</ApolloProvider>
);
2022-01-29 15:40:39 +00:00
}
export default MyApp;