-
-
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.
SSR - copy public folder when there is no client JS (#2955)
* SSR - copy public folder when there is no client JS * Changest * Use isBuildingToSSR Co-authored-by: JuanM04 <me@juanm04.com>
- Loading branch information
Showing
5 changed files
with
82 additions
and
2 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,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix for copying public when using SSR and not client JS |
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,7 @@ | ||
[ | ||
{ "name": "One" }, | ||
{ "name": "Two" }, | ||
{ "name": "Three" }, | ||
{ "name": "Four" }, | ||
{ "name": "Five" } | ||
] |
10 changes: 10 additions & 0 deletions
10
packages/astro/test/fixtures/ssr-request/src/pages/request.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,10 @@ | ||
--- | ||
const origin = new URL(Astro.request.url).origin; | ||
--- | ||
|
||
<html> | ||
<head><title>Testing</title></head> | ||
<body> | ||
<h1 id="origin">{origin}</h1> | ||
</body> | ||
</html> |
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,36 @@ | ||
|
||
import { expect } from 'chai'; | ||
import { load as cheerioLoad } from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
import testAdapter from './test-adapter.js'; | ||
|
||
// Asset bundling | ||
describe('Using Astro.request in SSR', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
projectRoot: './fixtures/ssr-request/', | ||
buildOptions: { | ||
experimentalSsr: true, | ||
}, | ||
adapter: testAdapter(), | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Gets the request pased in', async () => { | ||
const app = await fixture.loadTestAdapterApp(); | ||
const request = new Request('http://example.com/request'); | ||
const response = await app.render(request); | ||
const html = await response.text(); | ||
const $ = cheerioLoad(html); | ||
expect($('#origin').text()).to.equal('http://example.com'); | ||
}); | ||
|
||
it('public file is copied over', async () => { | ||
const json = await fixture.readFile('/client/cars.json'); | ||
expect(json).to.not.be.undefined; | ||
}); | ||
}); |