kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 194 forks source link

[SSR] Adding basePath to ROOT_URL alters intended url #508

Closed rikonor closed 7 years ago

rikonor commented 8 years ago

Hi,

I've noticed the following issue with the ssr branch.

When ROOT_URL has a basePath, e.g. ROOT_URL=http://localhost:8000/basePath - whenever the browser loads the page the path gets an additional basePath appended at the end of the url, e.g. visiting http://localhost:8000/basePath will "redirect" to http://localhost:8000/basePath/basePath.

This seems to be caused by router.js#L46.

I had tried to clone the ssr branch locally in order to try and fix this, but encountered an additional issue #507

mquandalle commented 8 years ago

Reproduced, will work on a fix.

rikonor commented 8 years ago

@mquandalle I realize, as you say, that the root cause may be Meteor.absoluteUrl. However, applying your fix locally did not fix the problem for me. The path still showed double basePath.

I managed to resolve this (at least temporarily) by commenting out router.js#L46.

Also, please notice an additional issue. Caching will fail when basePath is present. To fix it (again, temporarily until the root cause is fixed) I had to add the following:

// server/route.js
_cachePage(url, data, timeout) {
  // Fix URL to include _basePath
  url = `${FlowRouter.basePath}${url}`;
  ...
}