thunderhub/pages/api/v1.tsx
Anthony Potdevin 83d9b20205
chore: changes and config for ssr and nextjs (#26)
* test: change docker to yarn

* test: change api handler url

* fix: image imports in public folder

* fix: add path prefix to links

* chore: update deps

* chore: small fixes

* chore: remove prefetch flag

* chore: remove use size hook

* Revert "chore: remove prefetch flag"

This reverts commit ae7ee3bc23.
2020-04-16 10:57:22 +02:00

30 lines
688 B
TypeScript

import { ApolloServer } from 'apollo-server-micro';
import { thunderHubSchema } from '../../src/api/schemas';
import { getIp } from '../../src/api/helpers/helpers';
import getConfig from 'next/config';
import Cors from 'micro-cors';
const { publicRuntimeConfig } = getConfig();
const { apiBaseUrl } = publicRuntimeConfig;
const cors = Cors({
origin: true,
});
const apolloServer = new ApolloServer({
schema: thunderHubSchema,
context: async ({ req }: any) => {
const ip = getIp(req);
return { ip };
},
});
const handler = apolloServer.createHandler({ path: apiBaseUrl });
export const config = {
api: {
bodyParser: false,
},
};
export default cors(handler);