Skip to content

Commit

Permalink
feat: server cors
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Jul 21, 2024
1 parent 6913c5a commit 9373735
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/admin/nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { defineNitroConfig } from "nitropack/config";

export default defineNitroConfig({
timing: true,
routeRules: {
"/**": {
cors: true,
},
},
esbuild: {
options: {
target: "esnext",
Expand Down
16 changes: 16 additions & 0 deletions services/admin/plugins/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { consola } from "consola";
import { defineNitroPlugin } from "nitropack/runtime";

export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook("request", (event) => {
consola.start(`${event.method} ${event.path}`);
});

nitroApp.hooks.hook("error", (event, { body }) => {
consola.error(event.message, event.message, body);
});

nitroApp.hooks.hook("afterResponse", (event) => {
consola.success(`${event.method} ${event.path}`);
});
});

0 comments on commit 9373735

Please sign in to comment.