I sent such a request to h3 but always got a bad request error. Bad request
hoanghiep1x0 opened this issue · comments
hoanghiep1x0 commented
Environment
v20.12.0
"nuxt": "^3.11.2",
Reproduction
request body send
{"name":"adsense","order":1,"position":"head","code":"<script async src=\"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456\" crossorigin=\"anonymous\"></script>"}```
### Describe the bug
Just send a request with a string of html meta script code to put into the database and then retrieve it for use, but passing it to nitro with h3 always shows a bad request error.
```{
"url": "/api/scripts/create",
"statusCode": 400,
"statusMessage": "Bad Request",
"message": "Bad Request",
"stack": "<pre><span class=\"stack internal\">at createError (./node_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:79:15)</span>\n<span class=\"stack internal\">at Object.handler (./node_modules/.pnpm/nuxt-security@1.4.3/node_modules/nuxt-security/dist/runtime/server/middleware/xssValidator.mjs:44:19)</span>\n<span class=\"stack internal\">at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</span>\n<span class=\"stack internal\">at async ./node_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:1962:19</span>\n<span class=\"stack internal\">at async Object.callAsync (./node_modules/.pnpm/unctx@2.3.1/node_modules/unctx/dist/index.mjs:72:16)</span>\n<span class=\"stack internal\">at async Server.toNodeHandle (./node_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:2249:7)</span></pre>"
}```
### Additional context
_No response_
### Logs
```sh
{
"url": "/api/scripts/create",
"statusCode": 400,
"statusMessage": "Bad Request",
"message": "Bad Request",
"stack": "<pre><span class=\"stack internal\">at createError (./node_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:79:15)</span>\n<span class=\"stack internal\">at Object.handler (./node_modules/.pnpm/nuxt-security@1.4.3/node_modules/nuxt-security/dist/runtime/server/middleware/xssValidator.mjs:44:19)</span>\n<span class=\"stack internal\">at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</span>\n<span class=\"stack internal\">at async ./node_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:1962:19</span>\n<span class=\"stack internal\">at async Object.callAsync (./node_modules/.pnpm/unctx@2.3.1/node_modules/unctx/dist/index.mjs:72:16)</span>\n<span class=\"stack internal\">at async Server.toNodeHandle (./node_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:2249:7)</span></pre>"
}```
hoanghiep1x0 commented
sorry I found the problem caused by nuxt-security.