@astrojs/node
Advanced tools
Comparing version 5.1.2 to 5.1.3
# @astrojs/node | ||
## 5.1.3 | ||
### Patch Changes | ||
- [#7076](https://github.com/withastro/astro/pull/7076) [`781f558c4`](https://github.com/withastro/astro/commit/781f558c401a5f02927d150e4628a77c55cccd28) Thanks [@matthewp](https://github.com/matthewp)! - Fix redirects on directories when using base option | ||
## 5.1.2 | ||
@@ -4,0 +10,0 @@ |
@@ -40,2 +40,8 @@ import fs from "fs"; | ||
}); | ||
stream.on("directory", () => { | ||
const location = req.url + "/"; | ||
res.statusCode = 301; | ||
res.setHeader("Location", location); | ||
res.end(location); | ||
}); | ||
stream.on("file", () => { | ||
@@ -42,0 +48,0 @@ forwardError = true; |
import { polyfill } from "@astrojs/webapi"; | ||
import { NodeApp } from "astro/app/node"; | ||
import middleware from "./middleware.js"; | ||
import middleware from "./nodeMiddleware.js"; | ||
import startServer from "./standalone.js"; | ||
@@ -5,0 +5,0 @@ polyfill(globalThis, { |
@@ -5,3 +5,3 @@ import https from "https"; | ||
import { createServer } from "./http-server.js"; | ||
import middleware from "./middleware.js"; | ||
import middleware from "./nodeMiddleware.js"; | ||
function resolvePaths(options) { | ||
@@ -8,0 +8,0 @@ const clientURLRaw = new URL(options.client); |
{ | ||
"name": "@astrojs/node", | ||
"description": "Deploy your site to a Node.js server", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"type": "module", | ||
@@ -32,3 +32,3 @@ "types": "./dist/index.d.ts", | ||
"peerDependencies": { | ||
"astro": "^2.3.3" | ||
"astro": "^2.4.5" | ||
}, | ||
@@ -43,3 +43,3 @@ "devDependencies": { | ||
"undici": "^5.22.0", | ||
"astro": "2.3.3", | ||
"astro": "2.4.5", | ||
"astro-scripts": "0.0.14" | ||
@@ -46,0 +46,0 @@ }, |
@@ -58,3 +58,9 @@ import fs from 'fs'; | ||
}); | ||
stream.on('directory', () => { | ||
// On directory find, redirect to the trailing slash | ||
const location = req.url + '/'; | ||
res.statusCode = 301; | ||
res.setHeader('Location', location); | ||
res.end(location); | ||
}); | ||
stream.on('file', () => { | ||
@@ -61,0 +67,0 @@ forwardError = true; |
import { polyfill } from '@astrojs/webapi'; | ||
import type { SSRManifest } from 'astro'; | ||
import { NodeApp } from 'astro/app/node'; | ||
import middleware from './middleware.js'; | ||
import middleware from './nodeMiddleware.js'; | ||
import startServer from './standalone.js'; | ||
@@ -6,0 +6,0 @@ import type { Options } from './types'; |
@@ -6,3 +6,3 @@ import type { NodeApp } from 'astro/app/node'; | ||
import { createServer } from './http-server.js'; | ||
import middleware from './middleware.js'; | ||
import middleware from './nodeMiddleware.js'; | ||
import type { Options } from './types'; | ||
@@ -9,0 +9,0 @@ |
@@ -15,2 +15,3 @@ import nodejs from '../dist/index.js'; | ||
fixture = await loadFixture({ | ||
base: '/some-base', | ||
root: './fixtures/prerender/', | ||
@@ -36,3 +37,3 @@ output: 'server', | ||
it('Can render SSR route', async () => { | ||
const res = await fetch(`http://${server.host}:${server.port}/one`); | ||
const res = await fetch(`http://${server.host}:${server.port}/some-base/one`); | ||
const html = await res.text(); | ||
@@ -46,3 +47,3 @@ const $ = cheerio.load(html); | ||
it('Can render prerendered route', async () => { | ||
const res = await fetch(`http://${server.host}:${server.port}/two`); | ||
const res = await fetch(`http://${server.host}:${server.port}/some-base/two`); | ||
const html = await res.text(); | ||
@@ -56,3 +57,3 @@ const $ = cheerio.load(html); | ||
it('Can render prerendered route with query params', async () => { | ||
const res = await fetch(`http://${server.host}:${server.port}/two?foo=bar`); | ||
const res = await fetch(`http://${server.host}:${server.port}/some-base/two/?foo=bar`); | ||
const html = await res.text(); | ||
@@ -64,2 +65,10 @@ const $ = cheerio.load(html); | ||
}); | ||
it('Omitting the trailing slash results in a redirect that includes the base', async () => { | ||
const res = await fetch(`http://${server.host}:${server.port}/some-base/two`, { | ||
redirect: 'manual', | ||
}); | ||
expect(res.status).to.equal(301); | ||
expect(res.headers.get('location')).to.equal('/some-base/two/'); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104117
1567
8