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

headers errors #2047

Closed
thebergamo opened this issue Oct 24, 2014 · 4 comments
Closed

headers errors #2047

thebergamo opened this issue Oct 24, 2014 · 4 comments
Labels
support Questions, discussions, and general support

Comments

@thebergamo
Copy link

Hello!

I'm here again 👊

Well, today, I'm trying send a request for my API and I need send an custom header option: "x-token".
Validate is fine, but, I recive these error:

{
    "statusCode":400,
    "error":"Bad Request",
    "message":"host is not allowed. connection is not allowed. content-length is not allowed. cache-control is not allowed. origin is not allowed. content-type is not allowed. user-agent is not allowed. postman-token is not allowed. accept is not allowed. accept-encoding is not allowed. accept-language is not allowed",
    "validation":{
        "source":"headers",
        "keys":[
             "host",
             "connection",
             "content-length",
             "cache-control",
             "origin",
             "content-type",
             "user-agent",
             "postman-token",
             "accept",
             "accept-encoding",
             "accept-language"
         ]
    }
}

and my post request is:

data:
{
"action": "OMD"
}

headers: x-token: '12345678900987654321'

How I can solve this problem? Cors is enabled;

@arb
Copy link
Contributor

arb commented Oct 24, 2014

What are you using to try to test this endpoint? Are you using Postman by any chance? If you are, try using curl directly and see if that changes anything.

It would also help if you posted the route configuration as well.

@thebergamo
Copy link
Author

Well,

I find my mistake, when I try validate only one header and not include the others on the route config, hapi dispatch to me this error!

Well, have a way to I treat on validate some fields and others not?

@gergoerdosi
Copy link
Contributor

You can use the unknown() function: https://github.com/hapijs/joi#objectunknownallow

@thebergamo
Copy link
Author

hum... sound's good!

Thanks for yours replies is very useful for me!!

@hueniverse hueniverse added the support Questions, discussions, and general support label Oct 24, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

4 participants