aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-13 00:29:25 +0000
committerMohamedBassem <me@mbassem.com>2024-02-13 00:33:58 +0000
commit33c9e8bca54d753c7ea976dd178db0cd5408c218 (patch)
tree56099acd736a37845a7fce3a3ded0d399dbf5777 /packages/web
parentb00d2b360d8000edcd9bfa82673ca322a9ac6d1a (diff)
downloadkarakeep-33c9e8bca54d753c7ea976dd178db0cd5408c218.tar.zst
feature: A usable, yet ugly browser extension
Diffstat (limited to 'packages/web')
-rw-r--r--packages/web/app/api/trpc/[trpc]/route.ts7
-rw-r--r--packages/web/next.config.mjs29
2 files changed, 35 insertions, 1 deletions
diff --git a/packages/web/app/api/trpc/[trpc]/route.ts b/packages/web/app/api/trpc/[trpc]/route.ts
index e04539a9..aea9bc70 100644
--- a/packages/web/app/api/trpc/[trpc]/route.ts
+++ b/packages/web/app/api/trpc/[trpc]/route.ts
@@ -8,6 +8,13 @@ const handler = (req: Request) =>
endpoint: "/api/trpc",
req,
router: appRouter,
+ onError: ({ path, error }) => {
+ if (process.env.NODE_ENV === "development") {
+ console.error(`❌ tRPC failed on ${path}`);
+ }
+ console.error(error);
+ },
+
createContext: async (opts) => {
// TODO: This is a hack until we offer a proper REST API instead of the trpc based one.
// Check if the request has an Authorization token, if it does, assume that API key authentication is requested.
diff --git a/packages/web/next.config.mjs b/packages/web/next.config.mjs
index 4678774e..f2ed7754 100644
--- a/packages/web/next.config.mjs
+++ b/packages/web/next.config.mjs
@@ -1,4 +1,31 @@
/** @type {import('next').NextConfig} */
-const nextConfig = {};
+const nextConfig = {
+ async headers() {
+ return [
+ {
+ // Routes this applies to
+ source: "/api/(.*)",
+ // Headers
+ headers: [
+ // Allow for specific domains to have access or * for all
+ {
+ key: "Access-Control-Allow-Origin",
+ value: "*",
+ },
+ // Allows for specific methods accepted
+ {
+ key: "Access-Control-Allow-Methods",
+ value: "GET, POST, PUT, DELETE, OPTIONS",
+ },
+ // Allows for specific headers accepted (These are a few standard ones)
+ {
+ key: "Access-Control-Allow-Headers",
+ value: "Content-Type, Authorization",
+ },
+ ],
+ },
+ ];
+ },
+};
export default nextConfig;