diff --git a/site/src/api/api.ts b/site/src/api/api.ts index 83cb3dd2e0..210db89a29 100644 --- a/site/src/api/api.ts +++ b/site/src/api/api.ts @@ -4,6 +4,13 @@ import * as Types from "./types" import { DeploymentConfig } from "./types" import * as TypesGen from "./typesGenerated" +// Adds 304 for the default axios validateStatus function +// https://github.com/axios/axios#handling-errors +// Check status here https://httpstatusdogs.com/ +axios.defaults.validateStatus = (status) => { + return (status >= 200 && status < 300) || status === 304 +} + export const hardCodedCSRFCookie = (): string => { // This is a hard coded CSRF token/cookie pair for local development. // In prod, the GoLang webserver generates a random cookie with a new token for diff --git a/site/src/pages/TemplateSettingsPage/TemplateSettingsPage.tsx b/site/src/pages/TemplateSettingsPage/TemplateSettingsPage.tsx index 9fb935d731..9dca825501 100644 --- a/site/src/pages/TemplateSettingsPage/TemplateSettingsPage.tsx +++ b/site/src/pages/TemplateSettingsPage/TemplateSettingsPage.tsx @@ -18,8 +18,10 @@ export const TemplateSettingsPage: FC = () => { context: { templateName, organizationId }, actions: { onSave: (_, { data }) => { - // Use the data.name because the template name can be changed - navigate(`/templates/${data.name}`) + // Use the data.name because the template name can be changed. Since the + // API can return 304 if the template name is not changed, we use the + // templateName from the URL as default. + navigate(`/templates/${data.name ?? templateName}`) }, }, })