(request: Request)
| 109 | } |
| 110 | |
| 111 | const notFound = async (request: Request) => { |
| 112 | try { |
| 113 | const url = getRequestUrl(request, opts); |
| 114 | |
| 115 | // In the development server, we replace the getNotFound function |
| 116 | // For static paths, we assign a static "Not Found" message. |
| 117 | // This ensures consistency between development and production environments for specific URLs. |
| 118 | const notFoundHtml = isStaticPath(request.method || 'GET', url) |
| 119 | ? 'Not Found' |
| 120 | : getNotFound(url.pathname); |
| 121 | return new Response(notFoundHtml, { |
| 122 | status: 404, |
| 123 | headers: { 'Content-Type': 'text/html; charset=utf-8', 'X-Not-Found': url.pathname }, |
| 124 | }); |
| 125 | } catch (e) { |
| 126 | console.error(e); |
| 127 | return new Response(String(e || 'Error'), { |
| 128 | status: 500, |
| 129 | headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'bun-server' }, |
| 130 | }); |
| 131 | } |
| 132 | }; |
| 133 | |
| 134 | const openStaticFile = async (url: URL) => { |
| 135 | const pathname = url.pathname; |
no test coverage detected
searching dependent graphs…