DEV Community

Discussion on: How to host a Sapper.js SSR app on Firebase.

Collapse
 
eckhardtd profile image
Eckhardt

Mm, difficult to say, do you have a repo maybe? Is your firebase.json set like in the article? And are your external css and image files in your static folder?

Thread Thread
 
mortscode profile image
Mort • Edited

repo: github.com/mortscode/sapper-firebase

The issue in my browser console is that all of the asset urls are like so: http://localhost:5000/[firebase-project-name]/us-central1/ssr/global.css. They're all returning 404's.

Is there a location in the app where I should be defining that path?

One more thing, the command firebase init functions hosting didn't give me the hosting options in the console. I had to run firebase init hosting separately.

Thread Thread
 
focusat profile image
focus-at • Edited

works for me

const functions = require("firebase-functions");

// We have to import the built version of the server middleware.
const { sapper } = require("./sapper/build/server/server");
const middleware = sapper.middleware();

exports.ssr = functions.https.onRequest((req, res) => {
req.baseUrl = '';
middleware(req, res);
});

Thread Thread
 
eckhardtd profile image
Eckhardt

Hi Mort,

So sorry for the late reply. Have been taking a screen break.

Have you figured it out? I will look at your repo in my breaks.

Regards

Thread Thread
 
eckhardtd profile image
Eckhardt

I can't seem to replicate your problem, my urls are correct out of the box. I'll have to spend time finding the issue. I did however notice something else regarding versions of dependencies in the ./functions folder. It seems that I have to use the exact versions in package.json in functions here github.com/Eckhardt-D/sapper-fireb.... Strange. I'll explore. Sorry I don't have an off-the-cuff response.

Thread Thread
 
aslak01 profile image
aslak01

I'm having the exact same issue as Mort. I'm using newest versions in the functions package.json, as I got an error trying to use firebase admin 7.0.0. Once built and uploaded it works fine, but on localhost:5000 the firebase project name and useast1 time zone stuff shows up in the urls and causes 404s.

Thread Thread
 
mikedane profile image
Mike Dane

focus-at's solution worked for me, I'm using latest firebase-admin. I suspect this is a problem with the baseUrl var

Thread Thread
 
olyno profile image
Olyno

Hi,
Same issue here with latest versions. Any fix?

Thread Thread
 
bodhiz profile image
bodhiz

focus-at workaround worked for me as well.