apollo-server-hapi: add cors option to registerServer (#1085)

This commit is contained in:
Evans Hauser 2018-05-22 21:25:52 -07:00 committed by GitHub
parent 712a562858
commit 69be8c8429
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ export interface ServerRegistration {
options?: hapi.ServerOptions;
server: ApolloServerBase<hapi.Request>;
path?: string;
cors?: boolean;
}
export interface HapiListenOptions {
@ -27,6 +28,7 @@ export const registerServer = async ({
app,
options,
server,
cors,
path,
}: ServerRegistration) => {
if (!path) path = '/graphql';
@ -96,7 +98,7 @@ server.listen({ http: { port: YOUR_PORT_HERE } });
path: path,
graphqlOptions: server.request.bind(server),
route: {
cors: true,
cors: typeof cors === 'boolean' ? cors : true,
},
},
});