Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hapi v17.0.2 cors origin #3688

Closed
indreek opened this issue Nov 22, 2017 · 5 comments
Closed

Hapi v17.0.2 cors origin #3688

indreek opened this issue Nov 22, 2017 · 5 comments
Assignees
Labels
Milestone

Comments

@indreek
Copy link

@indreek indreek commented Nov 22, 2017

const server = Hapi.server({ port: 8080, routes: {cors: {origin: ['http://*.domain.com']} }});

What was the result you received?

(node:12710) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'match' of undefine

What did you expect?

Context

Cannot add cors origin with wildcard. * works, *.domain.com doesn't work.

Indrek

@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Nov 22, 2017

I cannot reproduce this. First, there is no promise generated for creating a new server so that line cannot generate an unhandled rejection. Second, you need to capture and log the full error so I can get the stack trace. Third, you need to provide a full example of what request you are sending to get this...

@indreek
Copy link
Author

@indreek indreek commented Nov 23, 2017

Code is here, but i will send you full error later.

const Hapi = require('hapi');
const server = Hapi.server({ port: 8080, routes: {cors: {origin: ['http://*.domain.com']} }});


server.route({ method: 'GET', path: '/test', handler: () => 'Hello test!', options: {tags: ['api']} });
server.route({
  path: '/foobar/{test?}',
  method: 'GET',
  options: {
    tags: ['api'],
    description: 'My route description',
    notes: 'My route notes',
    handler: (request, h) => {
      return 'Hello foobar!';
    }
  }
});

async function startup(){
  await server.start();
}

try{
  startup();
}
catch(err){
  console.log(err);
}

@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Nov 23, 2017

This code runs without an error. What request causes it to error?

@indreek
Copy link
Author

@indreek indreek commented Nov 23, 2017

Simple "curl http://localhost:8080/", "curl http://localhost:8080/test" and node outputs warning to console.

@hueniverse hueniverse self-assigned this Nov 23, 2017
@hueniverse hueniverse added the bug label Nov 23, 2017
@hueniverse hueniverse added this to the 17.1.1 milestone Nov 23, 2017
@lock
Copy link

@lock lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants