mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 02:01:40 -05:00
Hapi: reenable cors test
It seems that hapi does not send all allowed origins in the Access-Control-Allow-Origin header, so it is necessary to use another configuration option to see if the config is being propagated
This commit is contained in:
parent
209764324f
commit
c88630333c
2 changed files with 20 additions and 8 deletions
|
@ -183,18 +183,27 @@ describe('apollo-server-hapi', () => {
|
|||
});
|
||||
});
|
||||
|
||||
// XXX currently this test fails. Unsure why, since the otpins are passed
|
||||
// correctly to the server.route call in graphqlHapi
|
||||
xit('accepts cors configuration', async () => {
|
||||
it('accepts cors configuration', async () => {
|
||||
server = new ApolloServer({
|
||||
typeDefs,
|
||||
resolvers,
|
||||
});
|
||||
app = new Server({ port: 4000 });
|
||||
app = new Server({
|
||||
port: 4000,
|
||||
});
|
||||
|
||||
await server.applyMiddleware({
|
||||
app,
|
||||
cors: { origin: ['apollographql.com'] },
|
||||
cors: {
|
||||
additionalExposedHeaders: ['X-Apollo'],
|
||||
exposedHeaders: [
|
||||
'Accept',
|
||||
'Authorization',
|
||||
'Content-Type',
|
||||
'If-None-Match',
|
||||
'Another-One',
|
||||
],
|
||||
},
|
||||
});
|
||||
await app.start();
|
||||
|
||||
|
@ -203,9 +212,12 @@ describe('apollo-server-hapi', () => {
|
|||
|
||||
const apolloFetch = createApolloFetch({ uri }).useAfter(
|
||||
(response, next) => {
|
||||
console.log(response.response.headers);
|
||||
expect(
|
||||
response.response.headers.get('access-control-allow-origin'),
|
||||
).to.equal('apollographql.com');
|
||||
response.response.headers.get('access-control-expose-headers'),
|
||||
).to.deep.equal(
|
||||
'Accept,Authorization,Content-Type,If-None-Match,Another-One,X-Apollo',
|
||||
);
|
||||
next();
|
||||
},
|
||||
);
|
||||
|
|
|
@ -126,7 +126,7 @@ export class ApolloServer extends ApolloServerBase {
|
|||
await app.register({
|
||||
plugin: graphqlHapi,
|
||||
options: {
|
||||
path: path,
|
||||
path,
|
||||
graphqlOptions: this.createGraphQLServerOptions.bind(this),
|
||||
route: {
|
||||
cors: cors !== undefined ? cors : true,
|
||||
|
|
Loading…
Add table
Reference in a new issue