Giter Site home page Giter Site logo

Comments (5)

nahwinrajan avatar nahwinrajan commented on April 21, 2024 1

Function - set origin to a function implementing some custom logic. The function takes the request origin as the first parameter and a callback (which expects the signature err [object], allow [bool]) as the second.

the readme file state the second callback's parameter is a boolean

from cors.

dougwilson avatar dougwilson commented on April 21, 2024

This is not a bug, rather you accidentally made a mistake in your origin function. The second argument to callback needs to be the string of the origin to allow, but instead you are passing originsWhiteList[origin], which is actually the value true. Your function should be the following:

  origin: function(origin, callback) {
    callback(originsWhiteList[origin] ? null : 'Bad Request', origin);
  },

from cors.

dougwilson avatar dougwilson commented on April 21, 2024

Weird, then not sure. Can you issue a PR that fixes the issue you are having?

from cors.

nahwinrajan avatar nahwinrajan commented on April 21, 2024

I believe that only fault is at ReadMe.md file only,
the function actually expecting string of the allowed url (origin url, as you suggested)

from cors.

dougwilson avatar dougwilson commented on April 21, 2024

So after spending the past week getting to know this module better to help maintain it--it turns out that both are correct. The second argument you give to the callback can actually be any valid value to the origin option (so, an array, a string, a boolean, etc.).

from cors.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.