Skip to content

Commit 1b3d657

Browse files
committed
fixes #219; conflict detection not working
client generates their own updated time, rather than using the servers response timestamp, meaning if they are not in perfect sync the client may end up with a more recent time than the servers. Fixed by using servers timestamp given in http response.
1 parent 98d73c6 commit 1b3d657

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

backend/handlers/utils.go

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func SetupHandlers(
3333
AllowedOrigins: appConfig.CORSOrigins,
3434
AllowedMethods: []string{"HEAD", "GET", "POST", "PATCH", "PUT", "DELETE"},
3535
AllowedHeaders: []string{"*"},
36+
ExposedHeaders: []string{"Date"},
3637
AllowCredentials: true,
3738
}))
3839
config := huma.DefaultConfig("Note Mark - API", "0")

frontend/src/core/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ class Api {
365365
} catch (e) {
366366
return e
367367
}
368-
return new Date()
368+
return new Date(resp.headers.get("Date") || new Date().toISOString())
369369
}
370370
async restoreNoteById(noteId: string): Promise<Result<undefined, ApiError>> {
371371
let reqURL = `${this.apiServer}/notes/${noteId}/restore`

0 commit comments

Comments
 (0)