Skip to content

Commit 4a0c234

Browse files
committed
Fix flash cookie issue
1 parent 994014c commit 4a0c234

File tree

2 files changed

+38
-21
lines changed
  • apps/webapp/app

2 files changed

+38
-21
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
redirectWithErrorMessage,
5252
redirectWithSuccessMessage,
5353
getSession,
54+
commitSession,
5455
} from "~/models/message.server";
5556
import { findProjectBySlug } from "~/models/project.server";
5657
import { DeleteProjectService } from "~/services/deleteProject.server";
@@ -94,14 +95,20 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
9495

9596
const session = await getSession(request.headers.get("Cookie"));
9697
const openGitHubRepoConnectionModal = session.get("gitHubAppInstalled") === true;
98+
const headers = new Headers({
99+
"Set-Cookie": await commitSession(session),
100+
});
97101

98102
if (!githubAppEnabled) {
99-
return typedjson({
100-
githubAppEnabled,
101-
githubAppInstallations: undefined,
102-
connectedGithubRepository: undefined,
103-
openGitHubRepoConnectionModal,
104-
});
103+
return typedjson(
104+
{
105+
githubAppEnabled,
106+
githubAppInstallations: undefined,
107+
connectedGithubRepository: undefined,
108+
openGitHubRepoConnectionModal,
109+
},
110+
{ headers }
111+
);
105112
}
106113

107114
const userId = await requireUserId(request);
@@ -140,15 +147,20 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
140147
connectedGithubRepository.branchTracking
141148
);
142149

143-
return typedjson({
144-
githubAppEnabled,
145-
connectedGithubRepository: {
146-
...connectedGithubRepository,
147-
branchTracking: branchTrackingOrFailure.success ? branchTrackingOrFailure.data : undefined,
150+
return typedjson(
151+
{
152+
githubAppEnabled,
153+
connectedGithubRepository: {
154+
...connectedGithubRepository,
155+
branchTracking: branchTrackingOrFailure.success
156+
? branchTrackingOrFailure.data
157+
: undefined,
158+
},
159+
githubAppInstallations: undefined,
160+
openGitHubRepoConnectionModal,
148161
},
149-
githubAppInstallations: undefined,
150-
openGitHubRepoConnectionModal,
151-
});
162+
{ headers }
163+
);
152164
}
153165

154166
const githubAppInstallations = await prisma.githubAppInstallation.findMany({
@@ -182,12 +194,15 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
182194
},
183195
});
184196

185-
return typedjson({
186-
githubAppEnabled,
187-
githubAppInstallations,
188-
connectedGithubRepository: undefined,
189-
openGitHubRepoConnectionModal,
190-
});
197+
return typedjson(
198+
{
199+
githubAppEnabled,
200+
githubAppInstallations,
201+
connectedGithubRepository: undefined,
202+
openGitHubRepoConnectionModal,
203+
},
204+
{ headers }
205+
);
191206
};
192207

193208
const ConnectGitHubRepoFormSchema = z.object({

apps/webapp/app/utils/pathBuilder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ export function v3ProjectPath(organization: OrgForPath, project: ProjectForPath)
142142
}
143143

144144
export function githubAppInstallPath(organizationSlug: string, redirectTo: string) {
145-
return `/github/install?org_slug=${organizationSlug}&redirect_to=${redirectTo}`;
145+
return `/github/install?org_slug=${organizationSlug}&redirect_to=${encodeURIComponent(
146+
redirectTo
147+
)}`;
146148
}
147149

148150
export function v3EnvironmentPath(

0 commit comments

Comments
 (0)