Replies: 6 comments 6 replies
-
@beumsk Have you managed to successfully deploy the Remix application to Firebase hosting? |
Beta Was this translation helpful? Give feedback.
-
Deploying a Remix app via |
Beta Was this translation helpful? Give feedback.
-
@beumsk Have you been able to deploy this? I am currently having the same issues I Came here to ask the same only to see it has been asked. |
Beta Was this translation helpful? Give feedback.
-
Has anybody figure out how to do this? Writing a custom server to deploy to Firebase Functions is the only way I know. |
Beta Was this translation helpful? Give feedback.
-
Can someone share how the latest Remix Express server can be deployed to Firebase Functions? I am struggling to make it work for a Remix app built with vite and express server. |
Beta Was this translation helpful? Give feedback.
-
This is using Firebase Functions + Firebase Hosting + Remix + Vite. Note that Firebase Hosting caches all responses, so response streaming won't really be streamed, but buffered and sent as a whole when it's ready. Firebase's new App Hosting product is supposed to work with streaming, but I've since migrated from Firebase and haven't experimented with it. Bonus: this shows the easiest way to use TypeScript in Firebase Functions as they currently don't support it natively. P.S.: the imports use // File: firebase.json
// =============================================================================
{
"functions": {
"runtime": "nodejs18",
"source": "."
},
"hosting": {
"public": "./build/client",
"rewrites": [
{
"source": "**",
"function": {
"functionId": "ssr",
"pinTag": true
}
}
]
}
}
// File: server.ts
// =============================================================================
// ...
export const app = express()
// ...
// Only start the server if running this file directly. If running via Firebase,
// it will use the exported Express instance in its own server.
if (process.argv[1] === import.meta.url.replace('file://', '')) {
app.listen(port, () => {
console.log(`Listening at port ${port}`)
})
}
// File: functions/index.js
// =============================================================================
import { register } from 'tsx/esm/api'
register()
initializeApp(
process.env.FIREBASE_SERVICE_ACCOUNT
? {
credential: cert(JSON.parse(process.env.FIREBASE_SERVICE_ACCOUNT)),
}
: undefined,
)
export const { ssr } = await import('./functions.js')
// File: functions/functions.ts
// =============================================================================
import { onRequest } from 'firebase-functions/v2/https'
// Firebase Emulator loads this module twice: first simply for discovery, then
// to actually handle requests. In the second case, we need to load the server
// module because it will tell Remix the server is ready. In the first case
// though, we shouldn't load the server module because the required environment
// variables are not loaded and it would crash.
//
// IMPORTANT: after HMR, Firebase will kill the worker that runs this module
// and only restart it when a new request arrives, rendering HMR useless as such
// request won't happen. As a workaround, we need to pass '--inspect-functions'
// to `firebase emulators:start` which changes the behavior so the worker is
// forcefully restarted when the code is changed.
const server = process.env.FUNCTIONS_CONTROL_API
? null
: await import('../server.js')
export const ssr = onRequest(
{ memory: '2GiB', timeoutSeconds: 540 },
(request, response) => {
server.app(request, response)
},
) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm looking to deploy a remix app on to Firebase hosting.
I've been nowhere after several hours of trying and searching in the doc and on the internet so I reach out to you.
All I got is deploying an empty, default firebase site because it does not seem to take my built remix app into account.
I did follow firebase init, remix build, firebase deploy and the likes.
I think firebase needs a build output starting from index.html but I didn't manage to do that with remix build.
For the record, here are the useful files (i guess):
firebase.json
remix.config.js
Thanks already
Beta Was this translation helpful? Give feedback.
All reactions