Skip to content

Conversation

Yuangwang
Copy link
Collaborator

@Yuangwang Yuangwang commented Jan 22, 2025

Adds support for Astro in Firebase App Hosting.

To use follow these instructions:

  1. Install the @apphosting/astro-adapter Astro adapter with the following command in your terminal:
    npx astro add @apphosting/astro-adapter
  2. Add the adapter with the standalone rendering mode to your astro.config.* file:
import { defineConfig } from 'astro/config';
import node from '@apphosting/astro-adapter';

export default defineConfig({
  output: 'server',
  adapter: node({
    mode: 'standalone',
  }),
});
  1. Push the changes to github and kickoff a new rollout

@schmetti-dev
Copy link

local images are not showing up. Is there something i need to change to get it working or is this a bug?

image
image

const outputBundle: OutputBundleConfig = {
version: "v1",
runConfig: {
runCommand: `node dist/server/entry.mjs`,
Copy link
Collaborator

@jhuleatt jhuleatt Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path needs to respect the outDir option in astro.config. I think that can be done with the { dir } argument that is passed into this astro:build:done callback

setAdapter(getAdapter(_options));
},
"astro:build:done": async () => {
await fs.mkdir("./.apphosting");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await fs.mkdir("./.apphosting");
await fs.mkdir("./.apphosting", {
// Don't throw if directory already exists. Important when debugging the build locally
recursive: true
});

https://nodejs.org/dist/latest-v16.x/docs/api/fs.html#fsmkdirpath-options-callback:~:text=.%20Calling%20fs.mkdir()%20when%20path%20is%20a%20directory%20that%20exists%20results%20in%20an%20error%20only%20when%20recursive%20is%20false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants