Потрібна допомога у вирішенні проблеми CORS на React.js
17 USDЄ простий додаток на реакті, який звертається до зовнішнього апі
useEffect(() => {
axios.get('https://******/check_auth.php', {
withCredentials: true, // Додає cookie до запиту
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error('Error checking auth:', error);
});
}, []);на сервері я прописую CORS:
<?php
header("Access-Control-Allow-Origin: http://localhost:3000");
header("Access-Control-Allow-Credentials: true");
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => '**********',
'secure' => true,
'httponly' => true,
'samesite' => 'None'
]);
session_start();
print_r($_SESSION);
$_SESSION['test'] = "asfasfasfasfsfa";
Якщо зробити 2-3 оновлення сторінки то очікую що на друге оновлення має вивестись сесія з ключем тест, але весь час отримую пустий масив.
В консолі у вкладці кукі отримую попередження про різні домени
Але ж на бекенді я вказав 'samesite' => 'None', що йому ще не вистачає?
Може є якась інструкція як тестувати реакт додаток на локалхості щоб CORS не сварився? Бо коли вивантажуєш на сервер то все ок працює бо воно на одному домені.
Пробував прописати в package.json проксі
"proxy": "https://********",
але тоді npm start не запускається
Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.allowedHosts[0] should be a non-empty string.
Client's review of cooperation with freelancer
Потрібна допомога у вирішенні проблеми CORS на React.jsQuality work done. I recommend.
Freelancer's review of cooperation with Roman Nalivayko
Потрібна допомога у вирішенні проблеми CORS на React.jsIt was a pleasure to work. I recommend!!!!
![]()
-
2380 8 0 Hello, I am ready to help you solve your problem, feel free to reach out!
-
Спробуй погратись з mode на fetch api
mode: "cors", // no-cors, *cors, same-origin -
header("Access-Control-Allow-Origin: http://localhost:3000"); ->header("Access-Control-Allow-Origin: *"); -
Current freelance projects in the category Javascript and Typescript
Support and development of the cleaning company's website
20 USD
I'm looking for a web developer/webmaster for long-term support and development of a cleaning company's website. Website: https://donely.ca About the project DoneLy Home Services is a cleaning service company in Canada that is actively growing and expanding its geographical… Javascript and Typescript, Web Programming ∙ 15 hours 49 minutes back ∙ 53 proposals |
Development of a website according to the specifications on FramerYou need to create a website based on the parameters in the technical specification. https://docs.google.com/document/d/1ODO2C9Krb4AaMiJz9wfbNzWlAyA2FwCCHL8r0biajUY/edit?usp=sharing Please provide your actual rate based on this design. HTML & CSS, Javascript and Typescript ∙ 1 day 16 hours back ∙ 26 proposals |
Development of an interactive Palworld map for the websiteWe need to develop an interactive map for Palworld based on the example: https://palworld.gg/map We need not just a static image, but a full-fledged interactive map where users can view locations, toggle object categories on/off, search for specific points, and interact with… HTML & CSS, Javascript and Typescript ∙ 3 days 7 hours back ∙ 32 proposals |
Development of the AM Mobility platform (car service, parking, insurance, car rental)
5731 USD
We are looking for a team or an experienced Full Stack developer to create the MVP of the AM Mobility platform. AM Mobility is a unified digital ecosystem for motorists, combining in one application and web platform: parking; car service; tire fitting; car wash; car rental;… Javascript and Typescript, Web Programming ∙ 8 days 14 hours back ∙ 119 proposals |
Gsap animations
22 USD
Good day. Corrections need to be made in the current project. A specialist is needed who works well with gsap/lenis. Animation of cards needs to be done. Detailed specifications here:… Javascript and Typescript, Web Programming ∙ 8 days 19 hours back ∙ 21 proposals |