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

Feature request: Open up CORS by default #493

Closed
royduin opened this issue Jun 6, 2020 · 1 comment
Closed

Feature request: Open up CORS by default #493

royduin opened this issue Jun 6, 2020 · 1 comment
Labels
Feature request Feature Needs review Tickets that need review

Comments

@royduin
Copy link

royduin commented Jun 6, 2020

I've added

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: *');
header('Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Authorization,X-ReCaptcha,Store');

if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    http_response_code(200);
    exit;
}

At the beginnen of the server.php which seems to do the trick. Handling this in the Nginx config is also possible but then we've to catch the OPTIONS request there for the CORS preflight requests.

@royduin royduin added Feature request Feature Needs review Tickets that need review labels Jun 6, 2020
@mischabraam
Copy link
Member

I'm not a fan of implementing this in Valet+. I'd rather motivate you to figure out how to implement CORS headers into your application or nginx configuration on your production server. Adding this to Valet+ will give users questions like "it works on my dev mac, but not in production, why?".
As an alternative you could implement this in a local valet driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Feature Needs review Tickets that need review
Projects
None yet
Development

No branches or pull requests

2 participants