How to bypass Access-Control-Allow-Origin with PHP?

Spread the love

Sometimes, we want to bypass Access-Control-Allow-Origin with PHP.

In this article, we’ll look at how to bypass Access-Control-Allow-Origin with PHP.

How to bypass Access-Control-Allow-Origin with PHP?

To bypass Access-Control-Allow-Origin with PHP, we can set the Access-Control-Allow-Origin to the domains that we allow CORS for.

For instance, we write

header("Access-Control-Allow-Origin: https://www.example.com");

to allow CORS communication with https://www.example.com.

We can also write

header("Access-Control-Allow-Origin: *");

to allow CORS communication with all domains.

Conclusion

To bypass Access-Control-Allow-Origin with PHP, we can set the Access-Control-Allow-Origin to the domains that we allow CORS for.

Leave a Reply

Your email address will not be published.