Apollo-server: graphiqlExpress setup with endpoint that requires authentication and CORS?

Created on 5 May 2017  路  3Comments  路  Source: apollographql/apollo-server

Is there a way to configure graphql-express to use the graphiqlExpress configured with custom headers for authentication and handling CORS?

Most helpful comment

Ah, yes, thanks!

It definitely does feel hacky, as you'd have to do something like passHeader: '"token": "xxxxxx", \n "token2": "xxxxxxx"'

But works for me for now! Thanks @helfer

All 3 comments

@Magneticmagnum I think there's a way to essentially put a string in the header. It's a bit hacky, but it was used for the meteor integration. See passHeader here: https://github.com/apollographql/graphql-server/blob/79458e2ebb687a8dc76ee986ca1e5dd6dd3397eb/packages/graphql-server-module-graphiql/src/renderGraphiQL.ts#L17

If that doesn't do the trick for you, a clearer description of your use-case, and how important it is to you would be great!

Ah, yes, thanks!

It definitely does feel hacky, as you'd have to do something like passHeader: '"token": "xxxxxx", \n "token2": "xxxxxxx"'

But works for me for now! Thanks @helfer

Yeah most people eventually end up setting up a custom GraphiQL, or using the one in the Apollo dev tools.

Was this page helpful?
0 / 5 - 0 ratings