D
D
Denis Bukreev2017-04-21 00:11:45
Laravel
Denis Bukreev, 2017-04-21 00:11:45

What to do with cross-domain request between frontend part (reactJS) and backend part (laravel)?

So it goes.
I read some bullshit on google.
I found this solution on a foreign resource: 'header('Access-Control-Allow-Origin: *');and immediately remembered that I did something similar at the very beginning of my web career.
But where should I put this header in Laravel?
And how to properly restrict access to only one domain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2017-04-21
@denisbookreev

Access-Control-Allow-Origin can only go to a wildcard or a specific domain.
so for the whitelist of domains you need to feint:

SetEnvIf Origin "^http(s)?://(.+\.)?(domain\.org|domain2\.com)$" origin_is=$0 
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question