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

No 'Access-Control-Allow-Origin' #3

Open
webds opened this issue Jun 1, 2023 · 4 comments
Open

No 'Access-Control-Allow-Origin' #3

webds opened this issue Jun 1, 2023 · 4 comments

Comments

@webds
Copy link

webds commented Jun 1, 2023

https://github.com/leafsphp/cors/blob/10934a7504879ecf9b6f7687926c22a3b5c02ce9/src/Cors.php#LL71C4-L71C4

There is an error here.
If we want to set a custom Allow-Origin, we won't be able to do it.
For example, if I want to set the value "*", it will still not be accepted. The AJAX request will throw an error:
...has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

@webds
Copy link
Author

webds commented Jun 1, 2023

my quick solution

             if (static::isOriginAllowed($origin)) {
			$originHeader = ($origin == '*')?$origin:($_SERVER['HTTP_ORIGIN'] ?? $_SERVER['HTTP_HOST']);
			Headers::accessControl(
				'Allow-Origin',
				 $originHeader
			);
		}

@mychidarko
Copy link
Member

Hi @webds, I'm just seeing this issue. Do you mean you are not able to set your own origins using app()->cors()

@bbauti
Copy link

bbauti commented Sep 7, 2023

hey! im having the same error, i dont know what to do to solve it

@mychidarko
Copy link
Member

@webds @bbauti can you give some context here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

3 participants