fix(site): Don't handle 304 as error (#6655)

This commit is contained in:
Bruno Quaresma
2023-03-20 10:08:06 -03:00
committed by GitHub
parent 331a49bf75
commit a4d86e9d78
2 changed files with 11 additions and 2 deletions
+7
View File
@@ -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
@@ -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}`)
},
},
})