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

Cors issue is coming after applying validation on routes headers option #3761

Closed
Rajat28goyal opened this issue Mar 16, 2018 · 2 comments
Closed
Assignees
Labels
non issue Issue is not a problem or requires changes

Comments

@Rajat28goyal
Copy link

Rajat28goyal commented Mar 16, 2018

Hello,

I am facing issue of cors. If I apply validation on routes headers after allowing cors : true then it is giving an issue of cors in browser console that no "Access-control-allow-origin" is allowed in headers.
Route -

exports.logout = {
    method: 'PUT',
    path: '/logout',
    config: {
        description: 'logout',
        cors : true,
        auth: {
            scope: CONSTANTS.SCOPE.ADMIN
        },
        tags: ['api', 'admin'],
        handler: (request, h)=> {
            return Controller.lLogout(request.auth.credentials.authData, h)
                .then(response => {
                    return UniversalFunc.sendSuccess(SUCCESS.LOGOUT,response, h);
                })
                .catch(error => {
                    return UniversalFunc.sendError(error, h);
                });
        },
        validate: {
            headers: Joi.object().keys({authorization : Joi.string().required()}),
            failAction: UniversalFunc.failActionFunction
        }
    }
};

If I comment headers then all is working fine.

What can be issue?

  • node version: - 8.9.4
  • hapi version: - 17.2.0
  • os: - MAC
@hueniverse
Copy link
Contributor

Probably means your validation rule fails. For example, if the header name is upper case, it will fail.

@hueniverse hueniverse self-assigned this Mar 16, 2018
@hueniverse hueniverse added the non issue Issue is not a problem or requires changes label Mar 16, 2018
@lock
Copy link

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
non issue Issue is not a problem or requires changes
Projects
None yet
Development

No branches or pull requests

2 participants