morphbox
Version:
Docker-based AI sandbox for development with Claude integration
49 lines (46 loc) • 1.5 kB
JavaScript
import { g as getAuthConfig, i as isAuthenticated, a as getLoginPageHTML } from './auth-D2_ASaWH.js';
import 'crypto';
import 'fs';
import 'path';
import 'url';
import 'js-yaml';
console.log("🚀 Server running in packaged mode - managers handled by Docker");
const handle = async ({ event, resolve }) => {
const config = getAuthConfig();
const publicPaths = ["/api/auth/login", "/favicon.png", "/_app"];
const isPublicPath = publicPaths.some((path) => event.url.pathname.startsWith(path));
if (config.enabled && !isPublicPath) {
if (!isAuthenticated(event)) {
if (event.url.pathname.startsWith("/api/")) {
return new Response(JSON.stringify({ error: "Authentication required" }), {
status: 401,
headers: {
"Content-Type": "application/json"
}
});
}
return new Response(getLoginPageHTML(), {
status: 401,
headers: {
"Content-Type": "text/html"
}
});
}
}
return resolve(event);
};
const handleError = ({ error, event }) => {
console.error("Server error:", error);
console.error("Error context:", {
url: event.url.pathname,
method: event.request.method,
headers: Object.fromEntries(event.request.headers.entries()),
stack: error instanceof Error ? error.stack : void 0
});
return {
message: "Internal server error",
code: "SERVER_ERROR"
};
};
export { handle, handleError };
//# sourceMappingURL=hooks.server-DvxgeTHS.js.map