New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Solved] SSR doesn't use joinBase #593

Closed
leoj3n opened this Issue Oct 26, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@leoj3n
Copy link
Contributor

leoj3n commented Oct 26, 2018

SSR doesn’t seem to prepend dist/ using joinBase, so <img/> URLs come down 404ing until eventual client app reattachment which does finally update the tag srcs to properly prepend dist/.

Initial page as fetched from SSR:

image

Post client app reattachment (some milliseconds later):

image

Notice the unsightly 404 in the console.

@leoj3n

This comment has been minimized.

Copy link
Contributor

leoj3n commented Oct 27, 2018

Note that in the yellow Stache Variables part of the screenshots, this.env.NODE_ENV changes from production in SSR to development after reattachment. Could this be a hint as to what the issue may be? Anything I might be doing wrong, or a known bug? Any suggestions of what to try?

@matthewp

This comment has been minimized.

Copy link
Contributor

matthewp commented Oct 29, 2018

@leoj3n

This comment has been minimized.

Copy link
Contributor

leoj3n commented Oct 30, 2018

@matthewp Thanks for pointing me back in that direction. I found that example:

    "envs": {
      "server-production": {
        "renderingBaseURL": "https://place-my-order.firebaseapp.com/"
      }
    },

To be rather confusing at first, because my understanding is that setting renderingBaseURL to that https://place-my-order.firebaseapp.com/ doesn't really change anything; it's redundant because the app is already being served from that URL. So that example is a bit confusing for that reason.

Once I read up on server-production a bit more, and understood that means on the server (SSR) in production (as opposed to local development), I realized I have the tools to specifically target the URL used on the server to change it to exactly what it should be:

    "envs": {
      "server-production": {
        "renderingBaseURL": "https://bitcentivez.herokuapp.com/dist"
      }
    },

I still don't fully understand why window-production would prepend dist/, but server-production would not. It seems like window-production should have required the same kind of fix, or both window- and server-production should have worked out of the box. In the "following factors" section at the end of the joinBase docs:

https://canjs.com/doc/can-stache.helpers.joinBase.html

I don't necessarily see anything that would immediately suggest an answer as to why there would need to be a special separate config for how joinBase behaves on the server in SSR.

Anyways, I do think this is a nice feature, being able to specifically target the configuration not only using NODE_ENV, but also depending on window or server as well. At the very least it allows us to correct such kinds of unexpected behavior. I just wonder if this isn't a bug?

@matthewp

This comment has been minimized.

Copy link
Contributor

matthewp commented Oct 30, 2018

renderingBaseURL is sort of a weird feature. It only exists because on the server you don't want to point to where the files are on the server, but rather where the browser can download them from. There's nothing else like this in steal config so it's not a great fit. We should maybe think of a better way to do this in the future.

@leoj3n

This comment has been minimized.

Copy link
Contributor

leoj3n commented Oct 31, 2018

@matthewp Thanks, that makes sense.

Also, are there are no docs for renderingBaseUrl on https://stealjs.com? All I could find were the docs for https://stealjs.com/docs/config.baseURL.html which isn't the same thing.

I'll close this now as it's solved. Thanks again.

@leoj3n leoj3n closed this Oct 31, 2018

@leoj3n leoj3n changed the title SSR doesn't use joinBase [Solved] SSR doesn't use joinBase Nov 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment