Skip to content

Commit

Permalink
Rename env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
zoubingwu committed May 16, 2023
1 parent 87a36ae commit 786667e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
16 changes: 0 additions & 16 deletions lib/fetch.ts

This file was deleted.

15 changes: 14 additions & 1 deletion pages/api/gateway/[path].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from "next";
import { fetcher } from "~/lib/fetch";
import DigestFetch from "with-digest-fetch";

const client = new DigestFetch(
process.env.TIDBCLOUD_DATA_SERVICE_PUBLIC_KEY!,
process.env.TIDBCLOUD_DATA_SERVICE_PRIVATE_KEY!
);

const fetcher = async (key: string, body?: Record<string, any>) => {
const url = `${process.env.TIDBCLOUD_DATA_SERVICE_HOST}/${key}`;
const res = await client.fetch(url, {
body: body ? JSON.stringify(body) : body,
});
return await res.json();
};

export default async function handler(
req: NextApiRequest,
Expand Down

1 comment on commit 786667e

@vercel
Copy link

@vercel vercel bot commented on 786667e May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.