Giter Site home page Giter Site logo

Comments (4)

dougwilson avatar dougwilson commented on April 19, 2024

Hi @dcherman Inever heard of that header before, that was a good learning about! Sorry your issue sat here for a while; I'm recently looking after this module so trying to go through everything.

That being said, I think that it is out of scope for this module, since it does not fall into the realm of http://www.w3.org/TR/cors/ and there are probably use-cases where someone would want them configured independently. But there is a easy implementation for your desired state:

var cors = require('cors')
var onHeaders = require('on-headers')

// ... all your stuff

app.use(function (req, res, next) {
  onHeaders(res, function () {
    var allowOrigin = res.getHeader('Access-Control-Allow-Origin')
    if (allowOrigin) {
      res.setHeader('Timing-Allow-Origin', allowOrigin)
    }
  })
  next()
})
app.use(cors())

I hope this helps!

from cors.

jmpage avatar jmpage commented on April 19, 2024

@dougwilson at the time that you wrote your response over six years ago, Timing-Allow-Origin was not part of the CORS standard (link).

In 2019, it was added to the standard (whatwg/fetch#955) and it is currently included in the living CORS standard.

Is it worth revisiting the decision not to add support for Timing-Allow-Origin in this library?

from cors.

dougwilson avatar dougwilson commented on April 19, 2024

Hi @jmpage yea, it is part of the fetch spec, but still outside of the CORS part of the spec. You can find the CORS part only in section 3.2 of fetch you linked. That entire spec is all of fetch, with CORS on the server side, what this module is, only being section 3.2 .

from cors.

jmpage avatar jmpage commented on April 19, 2024

Got it and great point, thank you for your feedback, Doug!

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.