Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(devtools-server): broken auth flow in safari #5865

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -40,7 +40,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