eddev 0.3.34 → 0.3.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -10,6 +10,23 @@ module.exports = (() => {
|
|
|
10
10
|
const REPO_NAME = getRepoName(cwd.replace(/\/\.serverless/, "")).repoName
|
|
11
11
|
|
|
12
12
|
return withTM(["eddev"])({
|
|
13
|
+
async headers() {
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
source: "/:path*",
|
|
17
|
+
headers: [
|
|
18
|
+
{
|
|
19
|
+
key: "x-frame-options",
|
|
20
|
+
value: "DENY",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
key: "content-security-policy",
|
|
24
|
+
value: "frame-ancestors 'none'",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
]
|
|
29
|
+
},
|
|
13
30
|
rewrites() {
|
|
14
31
|
return {
|
|
15
32
|
afterFiles: [
|
|
@@ -47,7 +47,7 @@ export default async function (req: NextApiRequest, res: NextApiResponse) {
|
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
if (response.cacheFor) {
|
|
50
|
-
res.setHeader("Cache-Control", `
|
|
50
|
+
res.setHeader("Cache-Control", `public, s-maxage=${response.cacheFor}`)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
res.status(200).json(response.payload)
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
import { router, createContext } from "../../../apis/_rpc"
|
|
3
3
|
import * as trpcNext from "@trpc/server/adapters/next"
|
|
4
|
+
import { ResponseMetaFn } from "@trpc/server/dist/declarations/src/http/internals/types"
|
|
4
5
|
import type { NextApiRequest, NextApiResponse } from "next"
|
|
5
6
|
|
|
6
7
|
const handler = trpcNext.createNextApiHandler({
|
|
7
|
-
router: router,
|
|
8
|
+
router: router as any,
|
|
8
9
|
createContext: createContext,
|
|
10
|
+
responseMeta({ ctx, paths, type, errors, data }) {
|
|
11
|
+
// checking that no procedures errored
|
|
12
|
+
const allOk = errors.length === 0
|
|
13
|
+
// checking we're doing a query request
|
|
14
|
+
const isQuery = type === "query"
|
|
15
|
+
if (allOk && isQuery) {
|
|
16
|
+
return {
|
|
17
|
+
headers: {
|
|
18
|
+
"cache-control": `s-maxage=1, stale-while-revalidate=${ctx?.cacheTime || 60}`,
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {}
|
|
23
|
+
},
|
|
9
24
|
})
|
|
10
25
|
|
|
11
26
|
export default function (req: NextApiRequest, res: NextApiResponse) {
|