fix: 将编辑账单接口从 PATCH 改为 POST
- 修改后端路由:POST /api/bills/:id - 修改前端 API 调用方法为 POST - 移除临时添加的 CORS 中间件 - 解决生产环境 405 Method Not Allowed 问题
This commit is contained in:
@@ -47,7 +47,7 @@ func parseBillTime(s string) (time.Time, error) {
|
|||||||
return time.Time{}, fmt.Errorf("unsupported time format")
|
return time.Time{}, fmt.Errorf("unsupported time format")
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateBill PATCH /api/bills/:id 更新清洗后的账单记录
|
// UpdateBill POST /api/bills/:id 更新清洗后的账单记录
|
||||||
func UpdateBill(c *gin.Context) {
|
func UpdateBill(c *gin.Context) {
|
||||||
id := strings.TrimSpace(c.Param("id"))
|
id := strings.TrimSpace(c.Param("id"))
|
||||||
if id == "" {
|
if id == "" {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func setupAPIRoutes(r *gin.Engine) {
|
|||||||
authed.GET("/bills", handler.ListBills)
|
authed.GET("/bills", handler.ListBills)
|
||||||
|
|
||||||
// 编辑账单
|
// 编辑账单
|
||||||
authed.PATCH("/bills/:id", handler.UpdateBill)
|
authed.POST("/bills/:id", handler.UpdateBill)
|
||||||
|
|
||||||
// 手动创建账单
|
// 手动创建账单
|
||||||
authed.POST("/bills/manual", handler.CreateManualBills)
|
authed.POST("/bills/manual", handler.CreateManualBills)
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ export interface UpdateBillResponse {
|
|||||||
|
|
||||||
export async function updateBill(id: string, patch: UpdateBillRequest): Promise<UpdateBillResponse> {
|
export async function updateBill(id: string, patch: UpdateBillRequest): Promise<UpdateBillResponse> {
|
||||||
const response = await apiFetch(`${API_BASE}/api/bills/${encodeURIComponent(id)}`, {
|
const response = await apiFetch(`${API_BASE}/api/bills/${encodeURIComponent(id)}`, {
|
||||||
method: 'PATCH',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user