Skip to content

Commit a4d86e9

Browse files
fix(site): Don't handle 304 as error (coder#6655)
1 parent 331a49b commit a4d86e9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

site/src/api/api.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import * as Types from "./types"
44
import { DeploymentConfig } from "./types"
55
import * as TypesGen from "./typesGenerated"
66

7+
// Adds 304 for the default axios validateStatus function
8+
// https://github.com/axios/axios#handling-errors
9+
// Check status here https://httpstatusdogs.com/
10+
axios.defaults.validateStatus = (status) => {
11+
return (status >= 200 && status < 300) || status === 304
12+
}
13+
714
export const hardCodedCSRFCookie = (): string => {
815
// This is a hard coded CSRF token/cookie pair for local development.
916
// In prod, the GoLang webserver generates a random cookie with a new token for

site/src/pages/TemplateSettingsPage/TemplateSettingsPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ export const TemplateSettingsPage: FC = () => {
1818
context: { templateName, organizationId },
1919
actions: {
2020
onSave: (_, { data }) => {
21-
// Use the data.name because the template name can be changed
22-
navigate(`/templates/${data.name}`)
21+
// Use the data.name because the template name can be changed. Since the
22+
// API can return 304 if the template name is not changed, we use the
23+
// templateName from the URL as default.
24+
navigate(`/templates/${data.name ?? templateName}`)
2325
},
2426
},
2527
})

0 commit comments

Comments
 (0)