How to run CRA with authorization in Safari on localhost? #12763
-
On the first screen of my app I have a login form. The "Login" button sends POST-request to server side. In response I get a cookie with auth info. Then I send this cookie with all GET-requests. Also I use the "proxy" field in my package.json to avoid CORS problems. The issue appears when I try to run my app in Safari locally. Login form works fine, but auth cookie doesn't exist in any GET-request headers and I get the "401 Unauthorized" error. Well, the app does't work at all in Safari on localhost. I've tried to configure the proxy manually. Unfortunately, it doesn't solve the issue. Also I've tried to configure safari like described here but got the same result. Does anybody know how to setup proxy or safari to solve this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Finally I found the reason of this problem. My auth service sends the 'Set Cookie' response header with the 'secure' flag. But locally I run my app using 'http'. That is why Safari doesn't accept the cookie. To fix this issue I run my app using 'https'. I've added additional script to the 'package.json' file:
|
Beta Was this translation helpful? Give feedback.
Finally I found the reason of this problem. My auth service sends the 'Set Cookie' response header with the 'secure' flag. But locally I run my app using 'http'. That is why Safari doesn't accept the cookie. To fix this issue I run my app using 'https'.
I've added additional script to the 'package.json' file: