-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: #6131 * fix: delete * update code * fix: fix bug * add some tests * fix route error * delete comment * delete trash code --------- Co-authored-by: wuls <[email protected]>
- Loading branch information
1 parent
0049fda
commit ef5cea4
Showing
7 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'astro': patch | ||
'@astrojs/deno': patch | ||
--- | ||
|
||
Deno SSR with prerender=true complains about invalid URL scheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const DEFAULTIMPORT = `import { Server } from "https://deno.land/[email protected]/http/server.ts"; \n import { fetch } from "https://deno.land/x/file_fetch/mod.ts";\nimport { fileExtension } from "https://deno.land/x/[email protected]/mod.ts";` | ||
export const DEFAULTSTART = `const _start = 'start'; \n if(_start in adapter) { \nadapter[_start](_manifest, _args);}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
// Normal Imports | ||
import type { SSRManifest } from 'astro'; | ||
import { App } from 'astro/app'; | ||
// @ts-ignore | ||
import { Server } from 'https://deno.land/[email protected]/http/server.ts'; | ||
// @ts-ignore | ||
import { fetch } from 'https://deno.land/x/file_fetch/mod.ts'; | ||
|
||
|
||
interface Options { | ||
port?: number; | ||
hostname?: string; | ||
start?: boolean; | ||
} | ||
|
||
// @ts-ignore | ||
let _server: Server | undefined = undefined; | ||
let _startPromise: Promise<void> | undefined = undefined; | ||
|
||
|
@@ -39,8 +37,19 @@ export function start(manifest: SSRManifest, options: Options) { | |
// try to fetch a static file instead | ||
const url = new URL(request.url); | ||
const localPath = new URL('./' + app.removeBase(url.pathname), clientRoot); | ||
const fileResp = await fetch(localPath.toString()); | ||
|
||
const stringLocalPath = localPath.toString(); | ||
// @ts-ignore | ||
const extendName = fileExtension(stringLocalPath); | ||
const fileResp = await fetch( | ||
!extendName | ||
? `${ | ||
stringLocalPath.endsWith('/') | ||
? `${stringLocalPath}index.html` | ||
: `${stringLocalPath}/index.html` | ||
}` | ||
: stringLocalPath | ||
); | ||
|
||
// If the static file can't be found | ||
if (fileResp.status == 404) { | ||
// Render the astro custom 404 page | ||
|
@@ -60,6 +69,7 @@ export function start(manifest: SSRManifest, options: Options) { | |
}; | ||
|
||
const port = options.port ?? 8085; | ||
// @ts-ignore | ||
_server = new Server({ | ||
port, | ||
hostname: options.hostname ?? '0.0.0.0', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/integrations/deno/test/fixtures/basics/src/pages/perendering.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
export const prerender = true; | ||
--- | ||
|
||
<html> | ||
<body> | ||
<h1>test</h1> | ||
</body> | ||
</html> |