如何解决431错误 - 从硝基服务器返回基本64到Frontend
我目前正在研究一个项目,以了解有关NUXT 3的更多信息。
我正在将服务器端转换为图像,并希望将基本64字符串返回客户端:
// server/api/image.js
import imageToBase64 from 'image-to-base64'
export default defineEventHandler(async (event) => {
const param = useQuery(event)
const url = 'https://images-assets.nasa.gov/image/' + param.query + '/' + param.query + '~thumb.jpg'
return await imageToBase64(url)
.then(response => {
return response // base 64
})
.catch(error => console.log(error))
})
// test.vue
const base64 = await $fetch(`/api/image?query=${el.id}`)
但是我得到了431
错误并且不知道解决问题的正确方法。
获取http:// localhost:3000/9J/4aaqskzjrgabaqaaaqaaaqabaad/waalcaiaaoabarea/8qahwaaaqubacqol/[...] [http/1.1 431请求标头字段太大0ms]
您有什么想法吗?我只读要清除浏览器缓存...
I'm currently working on a project to learn more about Nuxt 3.
I am transforming an image on the server side and want to return a base 64 string back to the client:
// server/api/image.js
import imageToBase64 from 'image-to-base64'
export default defineEventHandler(async (event) => {
const param = useQuery(event)
const url = 'https://images-assets.nasa.gov/image/' + param.query + '/' + param.query + '~thumb.jpg'
return await imageToBase64(url)
.then(response => {
return response // base 64
})
.catch(error => console.log(error))
})
// test.vue
const base64 = await $fetch(`/api/image?query=${el.id}`)
But I got an 431
error and don't know the right approach to fix the problem.
GET http://localhost:3000/9j/4AAQSkZJRgABAQAAAQABAAD/wAALCAIAAoABAREA/8QAHwAAAQUBACQoL/ [...]
[HTTP/1.1 431 Request Header Fields Too Large 0ms]
Do you have any ideas? I only read about to clearing my browser cache...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论