[Next.js] Hide Sensitive Information from the Consumers of Next.js API
2023-09-14 08:59:12 时间
We'll learn how to use Next.js API Routes to hide sensitive information from the clients. In this case, we're calling the JSON Placeholder API with a "secret" value in the headers. All that sensitive information is hidden from the clients since they don't call, or even know, that we're calling the JSON Placeholder API under the hood.
async function getSuperSecretData() { const result = await fetch("https://jsonplaceholder.typicode.com/todos/1", { headers: { authorization: 'SUPER SECRET VALUE' } }).then(res => res.json()) return result } async function handler(req, res) { const secretTodo = await getSuperSecretData() res.json({todo: secretTodo}) } export default handler
authorization header won't be seen from the request in backend
相关文章
- vConsole 移动端 js 调试工具的简单使用
- JS框架_(Typed.js)彩色霓虹灯发光文字动画
- JS框架_(JQuery.js)带阴影贴纸标签按钮
- JS框架_(Laydate.js)简单实现日期日历
- 初探和实现websocket心跳重连(npm: websocket-heartbeat-js)
- js字符串替换
- JS魔法堂:函数重载 之 获取变量的数据类型
- js showOpenFilePicker showSaveFilePicker showDirectoryPicker API
- [Next.js] Create an API Route Using the next-connect Package
- [Node.js] Mock an API for Local Development in React with Mirage JS
- [Next.js] Consume Next.js API routes with the SWR library on the client-side
- [HTML 5 Performance] Measuring used JS heap size in chrome
- Cocos2d-JS中瓦片地图API
- js自动补全实例
- js逆向6-jshook,js扣代码
- [Node.js] Mock an API for Local Development in React with Mirage JS
- [Mise] Refetch API data when a state value changes with the `$watch` property in Alpine JS
- 说说backbone.js
- [FE] G2Plot 在 Vue 中使用 CDN 方式避免构建时增大 js 体积
- Atitit. 注册表操作查询 修改 api与工具总结 java c# php js python 病毒木马的原理
- Atitit.跨语言 java c#.net php js常用的codec encode算法api 兼容性 应该内置到语言里面
- 华为OD机试 - 对称美学(Java & JS & Python)
- 如何查看jsplumb.js的API文档(YUIdoc的基本使用)#华为云·寻找黑马程序员#
- electron中重写js 内置函数 需要重新内核编译
- 前端必备技能知识:JS导出Blob流文件为Excel表格、Vue.js使用Blob的方式实现excel表格的下载(流文件下载)
- JS工具方法 3 js客户端与php服务器通信加密之AES
- jquery分页插件pagination.js的使用