Giter VIP home page Giter VIP logo

Comments (19)

barryvdh avatar barryvdh commented on August 23, 2024

So the opposite of #49 ?

I understand the case, if you don't use credentials, I think * is probably fine and better for caching indeed.

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

So the opposite of #49 ?

Uhh... kind of. From reading #49 it seems a little misguided. If the the request needs to be varried by the Origin then it should always add it (even if it's not necessarily a cors request, as it could become one). If it doesn't need to be, it shouldn't be. I think adding this as configuration is more confusing.

In other words, this logic doesn't make any sense:

return $request->headers->has('Origin') && !$this->isSameHost($request);

because if the request is missing the Origin header (for wahtever reason) or comes from the same Origin it gets cached as a non-cors request, which would break all subsequent cross-origin requests. :(

I think it should follow this logic:

if ( $config['supportsCredentials'] === true || $config['allowedOrigins'] !== ['*']) {
  // Set or append `Origin` to `Vary` header on all requests.
}

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

FYI: This is still an issue because of:

if (!$this->cors->isCorsRequest($request)) {
return $this->app->handle($request, $type, $catch);
}

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

Lastly, we should deal with this:

stack-cors/src/Cors.php

Lines 48 to 50 in 456655a

if ($this->cors->isPreflightRequest($request)) {
return $this->cors->handlePreflightRequest($request);
}

at a minimum, it should check that the method is OPTIONS first:

public function isPreflightRequest(Request $request)
{
return $this->isCorsRequest($request)
&& $request->getMethod() === 'OPTIONS'
&& $request->headers->has('Access-Control-Request-Method');
}

from stack-cors.

barryvdh avatar barryvdh commented on August 23, 2024

Can we close this now?

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

Can we close this now?

Yep! It looks so beautiful! :) Thank you so much!

from stack-cors.

barryvdh avatar barryvdh commented on August 23, 2024

Okay I've tagged a 2.0.0-beta1 so please test it out :)

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

Okay I've tagged a 2.0.0-beta1 so please test it out :)

Oh where was the breaking change?

from stack-cors.

barryvdh avatar barryvdh commented on August 23, 2024

Well, the behavior has changed a bit imho, not sure if that qualifies as actually breaking. Is that a problem?

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

Well, the behavior has changed a bit imho, not sure if that qualifies as actually breaking. Is that a problem?

I have no idea, I can submit the Drupal patch. :)

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

Looking at https://semver.org/ it seems like this would be a minor since we didn't change the public API at all. The breaking change would be removing the methods we no longer use. :) but your call. :)

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

I guess the question is: Does this change break backwards compatability? It doesn't seem like it does. I could argue that it's actually a bug fix and not even a new feature.

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

Seems like it would be wise to release a beta version of the point release (i.e. 1.4.0-beta1) though.

from stack-cors.

GrahamCampbell avatar GrahamCampbell commented on August 23, 2024

A breaking change to semantics is also a breaking change, even if there's no breaking changes to the signatures.

from stack-cors.

GrahamCampbell avatar GrahamCampbell commented on August 23, 2024

2.0.0-beta1 was the right choice.

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

A breaking change to semantics is also a breaking change, even if there's no breaking changes to the signatures.

https://semver.org/ defines a breaking change as a change in the "Public API" not to the semantics, but true you may define the Public API however you want. :)

from stack-cors.

GrahamCampbell avatar GrahamCampbell commented on August 23, 2024

A change to the semantics IS a breaking change to the public API...

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

A change to the semantics IS a breaking change to the public API...

well I'm not sure how anyone could argue with that level of circular reasoning.

from stack-cors.

davidbarratt avatar davidbarratt commented on August 23, 2024

Here's the issue in Drupal's Queue
https://www.drupal.org/project/drupal/issues/3128982

from stack-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.