Merge pull request #2986 from Infisical/misc/addressed-cf-pages-error-304

fix: addressed cloudflare pages error 304
This commit is contained in:
Maidul Islam
2025-01-14 10:42:42 -05:00
committed by GitHub
2 changed files with 34 additions and 22 deletions
@@ -3711,11 +3711,10 @@ const syncSecretsCloudflarePages = async ({
const getSecretsRes = ( const getSecretsRes = (
await request.get<{ await request.get<{
result: { deployment_configs: Record<string, { env_vars: Record<string, unknown> }> }; result: { deployment_configs: Record<string, { env_vars: Record<string, unknown> }> };
}>(`${IntegrationUrls.CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accessId}/pages/projects/${integration.app}?_=${Date.now()}`, { }>(`${IntegrationUrls.CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accessId}/pages/projects/${integration.app}`, {
headers: { headers: {
Authorization: `Bearer ${accessToken}`, Authorization: `Bearer ${accessToken}`,
Accept: "application/json", Accept: "application/json"
"Cache-Control": "no-store"
} }
}) })
).data.result.deployment_configs[integration.targetEnvironment as string].env_vars; ).data.result.deployment_configs[integration.targetEnvironment as string].env_vars;
@@ -3751,8 +3750,9 @@ const syncSecretsCloudflarePages = async ({
); );
const metadata = z.record(z.any()).parse(integration.metadata); const metadata = z.record(z.any()).parse(integration.metadata);
if (metadata.shouldAutoRedeploy) { if (metadata.shouldAutoRedeploy && integration.targetEnvironment === "production") {
await request.post( await request
.post(
`${IntegrationUrls.CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accessId}/pages/projects/${integration.app}/deployments`, `${IntegrationUrls.CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accessId}/pages/projects/${integration.app}/deployments`,
{}, {},
{ {
@@ -3761,7 +3761,17 @@ const syncSecretsCloudflarePages = async ({
Accept: "application/json" Accept: "application/json"
} }
} }
)
.catch((error) => {
if (error instanceof AxiosError && error.response?.status === 304) {
logger.info(
`syncSecretsCloudflarePages: CF pages redeployment returned status code 304 for integration [id=${integration.id}]`
); );
return;
}
throw error;
});
} }
}; };
@@ -192,6 +192,7 @@ export const CloudflarePagesConfigurePage = () => {
))} ))}
</Select> </Select>
</FormControl> </FormControl>
{targetEnvironment === "production" && (
<div className="mb-[2.36rem] ml-1 px-6"> <div className="mb-[2.36rem] ml-1 px-6">
<Switch <Switch
id="redeploy-cloudflare-pages" id="redeploy-cloudflare-pages"
@@ -201,6 +202,7 @@ export const CloudflarePagesConfigurePage = () => {
Auto-redeploy service upon secret change Auto-redeploy service upon secret change
</Switch> </Switch>
</div> </div>
)}
<Button <Button
onClick={handleButtonClick} onClick={handleButtonClick}
color="mineshaft" color="mineshaft"