Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> The value of the 'Access-Control-Allow-Credentials' header in the response is 'true, true' which must be 'true' when the request's credentials mode is
throw.pl
post 30.06.2017, 12:22:48
Post #1





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 23.09.2009

Ostrzeżenie: (0%)
-----


Czy ktoś wie jak naprawić taki błąd?

W kodzie PHP mam:

  1. header('Access-Control-Allow-Credentials: true');


ale w konsoli przeglądarki dostaję następujący błąd:

The value of the 'Access-Control-Allow-Credentials' header in the response is 'true, true' which must be 'true' when the request's credentials mode is 'include'.

Próbowałem na różne sposoby :/

Pełen kod to:

  1. $tmp = parse_url($_SERVER['HTTP_REFERER']);
  2. if(isset($_SERVER['HTTP_ORIGIN']))
  3. {
  4. header('Access-Control-Allow-Origin: '.trim($_SERVER['HTTP_ORIGIN']));
  5. } else {
  6. header('Access-Control-Allow-Origin: '.trim($tmp['scheme'].'://'.$tmp['host']));
  7. }
  8. header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
  9. header('Access-Control-Allow-Headers: X-Requested-With, Origin, Content-Type, X-Auth-Token');
  10. header('Access-Control-Allow-Credentials: true');


Jest to zrobione w taki sposób, bo chcę obsługiwać zapytania z dowolnej domeny, a nie mogę edytować .htaccess (a w zasadzie mogę, ale nic to nie daje).


--------------------
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
nospor
post 30.06.2017, 12:26:51
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Problem z AJAX nie ma zadnego zwiazku. Przenosze

Nie wysylasz przypadkiem jeszcze gdzies indziej tego naglowka? W innej czesci kod, moze w .htaccess ktore ewidentnie tez zmieniales?


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
throw.pl
post 30.06.2017, 12:53:19
Post #3





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 23.09.2009

Ostrzeżenie: (0%)
-----


No właśnie nie. Mi to wygląda jak jakis bład w samym PHP.
Najdziwniejsze jest to, że gdy zrobię:
  1. header('Access-Control-Allow-Credentials: true');


to do przeglądarki wysyła:

  1. Access-Control-Allow-Credentials: true, true


--------------------
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
Go to the top of the page
+Quote Post
viking
post 30.06.2017, 13:10:32
Post #4





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Dodałem na szybko, nagłówki odpowiedzi
Access-Control-Allow-Credentials "true"
ewidentnie jest dobrze.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 05:30