Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/dokploy/pages/api/providers/gitlab/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default async function handler(
return res.status(400).json({ error: "Missing or invalid code" });
}

const gitlab = await findGitlabById(gitlabId as string);
const gitlab = await findGitlabById(gitlabId);
// Use internal URL for token exchange when GitLab is on same instance as Dokploy
const baseUrl = gitlab.gitlabInternalUrl || gitlab.gitlabUrl;
const gitlabUrl = new URL(baseUrl);
Expand Down Expand Up @@ -39,9 +39,9 @@ export default async function handler(
method: "POST",
headers,
body: new URLSearchParams({
client_id: gitlab.applicationId as string,
client_secret: gitlab.secret as string,
code: code as string,
client_id: gitlab.applicationId,
client_secret: gitlab.secret,
code: code,
grant_type: "authorization_code",
redirect_uri: `${gitlab.redirectUri}?gitlabId=${gitlabId}`,
}),
Expand All @@ -53,7 +53,7 @@ export default async function handler(
return res.status(400).json({ error: "Missing or invalid code" });
}

const expiresAt = Math.floor(Date.now() / 1000) + result.expires_in;
const expiresAt = result.expires_in ? Math.floor(Date.now() / 1000) + result.expires_in : `Error receiving expires_in, expected type: number, but currently received: ${result.expires_in}`;
await updateGitlab(gitlab.gitlabId, {
accessToken: result.access_token,
refreshToken: result.refresh_token,
Expand Down