Skip to content

Commit

Permalink
fix(devtools-server): broken auth flow in safari (#5865)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliemir committed Apr 24, 2024
1 parent 8d2dd43 commit a9dbd80
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .changeset/loud-toes-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@refinedev/devtools-server": patch
---

fix: devtools authentication not working with safari

Fixed the authentication flow and cookie handling for Safari. Now devtools users will be able to authenticate and use the devtools server using Safari.

Resolves [#5753](https://github.com/refinedev/refine/issues/5753)
2 changes: 1 addition & 1 deletion packages/devtools-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"dev:client": "vite build --watch --force --config src/client/vite.config.ts",
"prepare": "npm run build",
"publint": "publint --strict=true --level=suggestion",
"start:server": "node dist/cli.js",
"start:server": "node dist/cli.cjs",
"test": "jest --passWithNoTests --runInBand",
"types": "node ../shared/generate-declarations.js"
},
Expand Down
9 changes: 8 additions & 1 deletion packages/devtools-server/src/serve-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const serveProxy = async (app: Express) => {
changeOrigin: true,
pathRewrite: { "^/api/.auth": "/.auth" },
cookieDomainRewrite: {
"refine.dev": "",
"refine.dev": "localhost",
},
logLevel: __DEVELOPMENT__ ? "debug" : "silent",
headers: {
Expand All @@ -156,6 +156,13 @@ export const serveProxy = async (app: Express) => {
}
},
onProxyRes: (proxyRes, req, res) => {
const newSetCookie = proxyRes.headers["set-cookie"]?.map((cookie) =>
cookie
.replace("Domain=refine.dev;", "Domain=localhost;")
.replace(" HttpOnly; Secure; SameSite=Lax", ""),
);
if (newSetCookie) proxyRes.headers["set-cookie"] = newSetCookie;

if (req.url.includes("self-service/methods/oidc/callback")) {
return handleSignInCallbacks((_token, _jwt) => {
token = _token;
Expand Down

0 comments on commit a9dbd80

Please sign in to comment.