mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
add support for /admin route in backend handler and enable asset copying
updated `hooks.server.ts` to handle `/admin` routes and prevent fallback for 404 responses. added `adminBasepath` config to match backend paths. introduced assets copying step via `postinstall` script and included `robots.txt` and `favicon.ico` under `static`.
This commit is contained in:
2
examples/sveltekit/.gitignore
vendored
2
examples/sveltekit/.gitignore
vendored
@@ -9,3 +9,5 @@ node_modules
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
*.db
|
||||
static/manifest.json
|
||||
static/assets
|
||||
@@ -35,6 +35,10 @@ export default {
|
||||
},
|
||||
},
|
||||
},
|
||||
adminOptions: {
|
||||
// this path must be the same as in `hooks.server.ts`
|
||||
adminBasepath: "/admin"
|
||||
},
|
||||
options: {
|
||||
seed: async (ctx) => {
|
||||
await ctx.app.module.auth.createUser({
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
"preview": "vite preview",
|
||||
"postinstall": "node node_modules/.bin/bknd copy-assets --out static"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "^7.0.0",
|
||||
|
||||
@@ -7,8 +7,12 @@ const bkndHandler = serve(config, env);
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
// Handle bknd API requests
|
||||
if (event.url.pathname.startsWith("/api/")) {
|
||||
return bkndHandler(event);
|
||||
const pathname = event.url.pathname;
|
||||
if (pathname.startsWith("/api/") || pathname.startsWith("/admin")) {
|
||||
const res = await bkndHandler(event);
|
||||
if (res.status !== 404) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return resolve(event);
|
||||
|
||||
BIN
examples/sveltekit/static/favicon.ico
Normal file
BIN
examples/sveltekit/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
3
examples/sveltekit/static/robots.txt
Normal file
3
examples/sveltekit/static/robots.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# allow crawling everything by default
|
||||
User-agent: *
|
||||
Disallow:
|
||||
Reference in New Issue
Block a user