47ng / 47ng/nuqs

AWS API Gateway returns 400 when {} are present in query values

未關閉
#1,114 6 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
TypeScript
星號
10.8k
分支
294
平均合併
1 天 16 小時
30 天內合併 PR
21

描述

## Context

What's your version of `nuqs`?

```
"nuqs": "2.5.2",
```

What framework are you using?

- ✅ Next.js (app router)

Which version of your framework are you using?

```
"next": "14.2.32",
```

## Description
- Requests to AWS API Gateway with `{}` in query values fail with 400 bad request (and appear to hard-crash the gateway, because no execution or access logs appear in CloudWatch for these requests)
- I am trying to use `parseAsJson`, which ends up serializing `{ hello: ['a', 'b'] }` as `{%22hello%22:[%22a%22,%22b%22]}`
- I expect `{}` to be URL-escaped into `%7B` and `%7D` respectively
- `:`, `[`, and `]` do not need to be escaped - AWS API Gateway works fine with those as-is

## Reproduction
- I do not have any public API Gateway services right now
- I could look into creating one if needed

## Related
- #1069
- #1068
- #925

貢獻指南

開啟貢獻指南

研究方向

查看 nuqs 原始碼中的 parseAsJson serializer,它可能位於類似 src/parsers.ts 或 src/serializer.ts 的檔案中。問題在於,將 JSON 物件序列化為查詢字串時,大括號 {} 沒有進行 URL 編碼。檢查該函式庫目前如何編碼查詢值,並將其與 URL 編碼標準進行比較。使用 Next.js 和模擬的 AWS API Gateway 端點建立最小重現,以驗證編碼後的值是否有效,藉此測試修正。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
aws, next.js
領域
api, backend
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。