Skip to content

Commit

Permalink
add protection if astro preview is run with server output (#4284)
Browse files Browse the repository at this point in the history
Co-authored-by: Nate Moore <[email protected]>
  • Loading branch information
FredKSchott and natemoo-re authored Aug 13, 2022
1 parent d54588c commit 73f367c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-insects-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Prevent preview if 'output: server' is configured
2 changes: 1 addition & 1 deletion packages/astro/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function printAstroHelp() {
printHelp({
commandName: 'astro',
usage: '[command] [...flags]',
headline: 'Futuristic web development tool.',
headline: 'Build faster websites.',
tables: {
Commands: [
['add', 'Add an integration.'],
Expand Down
3 changes: 3 additions & 0 deletions packages/astro/src/core/preview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export default async function preview(
config: AstroConfig,
{ logging }: PreviewOptions
): Promise<PreviewServer> {
if (config.output === 'server') {
throw new Error(`[preview] 'output: server' not supported. Use your deploy platform's preview command directly instead, if one exists. (ex: 'netlify dev', 'vercel dev', 'wrangler', etc.)`);
}
const startServerTime = performance.now();
const defaultOrigin = 'http://localhost';
const trailingSlash = config.trailingSlash;
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ describe('astro cli', () => {

it('astro', async () => {
const proc = await cli();

expect(proc.stdout).to.include('Futuristic web development tool');
expect(proc.exitCode).to.equal(0);
});

it('astro --version', async () => {
Expand Down

0 comments on commit 73f367c

Please sign in to comment.