mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-22 14:22:33 +01:00
* 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
.
30 lines
688 B
TypeScript
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);
|