Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions site/src/pages/TemplateSettingsPage/TemplateSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
},
},
})
Expand Down