Skip to content

Commit 3d6a710

Browse files
committed
Update axios public client to set withCredentials
1 parent 3d724ae commit 3d6a710

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

backend/app/Services/Infrastructure/Session/CheckoutSessionManagementService.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace HiEvents\Services\Infrastructure\Session;
44

5+
use Illuminate\Config\Repository;
56
use Illuminate\Http\Request;
67
use Illuminate\Support\Facades\Cookie;
78
use Illuminate\Support\Str;
@@ -14,7 +15,8 @@ class CheckoutSessionManagementService
1415
private ?string $sessionId = null;
1516

1617
public function __construct(
17-
private readonly Request $request,
18+
private readonly Request $request,
19+
private readonly Repository $config,
1820
)
1921
{
2022
}
@@ -43,6 +45,7 @@ public function getSessionCookie(): SymfonyCookie
4345
return Cookie::make(
4446
name: self::SESSION_IDENTIFIER,
4547
value: $this->getSessionId(),
48+
domain: $this->config->get('session.domain') ?? '.' . $this->request->getHost(),
4649
secure: true,
4750
sameSite: 'None',
4851
);

backend/config/cors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
'allowed_methods' => ['*'],
2121

22-
'allowed_origins' => [env('CORS_ALLOWED_ORIGINS', '*')],
22+
'allowed_origins' => explode(',', env('CORS_ALLOWED_ORIGINS', '*')),
2323

2424
'allowed_origins_patterns' => [],
2525

frontend/src/api/public-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import axios from "axios";
22
import {isSsr} from "../utilites/helpers";
33
import {getConfig} from "../utilites/config";
44

5-
export const publicApi = axios.create();
5+
export const publicApi = axios.create({
6+
withCredentials: true,
7+
});
68

79
const existingToken = typeof window !== "undefined" ? window?.localStorage?.getItem('token') : undefined;
810

0 commit comments

Comments
 (0)