Skip to content
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

Incorrect Relative Paths for Resources - Cannot Reverse Proxy #94

Open
dnut opened this issue Sep 3, 2016 · 1 comment
Open

Incorrect Relative Paths for Resources - Cannot Reverse Proxy #94

dnut opened this issue Sep 3, 2016 · 1 comment

Comments

@dnut
Copy link

dnut commented Sep 3, 2016

Kaiwa uses paths relative to root, eg:

/styles.nonCached.css
/app.noncached.js
/config.js

This causes a problem when reverse proxying. You can reverse proxy a subdomain just fine, say chat.example.com, because your resources would be at root. However, I don't pay for wildcard ssl, so I want to reverse proxy example.com/chat to example.com:8000. All the paths given by Kaiwa are relative to root, so it's looking for example.com/config.js instead of example.com/chat/config.js.

There is a simple fix for this. Just add a dot in front of every path to make the paths more relative:

./styles.nonCached.css
./app.noncached.js
./config.js

I went through the jade views and tried implementing this fix, but it only fixed some minor things like images. Overall the client is still useless when reverse proxied through a non-root path because I can't find all the paths that need fixing.

@dnut
Copy link
Author

dnut commented Sep 4, 2016

I made some progress, but it doesn't work that well. It doesn't always go to the right pages, but if you push it here and there it sort of finds its way. Definitely needs some more work.

diff ./views.bak/index.jade ./views/index.jade
5,6c5,6
<         link(rel='stylesheet', href=locals.resourcePrefix + locals.cssFileName)
<         script(src=locals.resourcePrefix + locals.jsFileName)
---
>         link(rel='stylesheet', href='.' + locals.resourcePrefix + locals.cssFileName)
>         script(src='.' + locals.resourcePrefix + locals.jsFileName)
8c8
<         script(src="/config.js")
---
>         script(src="./config.js")
11c11
<             img(id="logo", src="/images/logo-big.png", width="250", height="77", alt="DrewChat")
---
>             img(id="logo", src="./images/logo-big.png", width="250", height="77", alt="DrewChat")
14c14
<             a.button.secondary(href="/logout") Cancel
---
>             a.button.secondary(href="./logout") Cancel
diff ./views.bak/layout.jade ./views/layout.jade
6c6
<         link(rel="stylesheet", href="/css/client.css")
---
>         link(rel="stylesheet", href="../css/client.css")
11c11
<             img#logo(src="/images/logo-big.png", width="250", height="77", alt="Kaiwa")
---
>             img#logo(src="../images/logo-big.png", width="250", height="77", alt="Kaiwa")
14c14
<         script(src='/js/zepto.js')
---
>         script(src='../js/zepto.js')
diff ./views.bak/login.jade ./views/login.jade
25,26c25,26
<     script(src="/config.js")
<     script(src="/js/login.js")
---
>     script(src="../config.js")
>     script(src="../js/login.js")
diff ./views.bak/logout.jade ./views/logout.jade
4c4
<     script(src="/js/logout.js")
---
>     script(src="./js/logout.js")
diff ./views.bak/oauthLogin.jade ./views/oauthLogin.jade
4c4
<     script(src="/js/oauthLogin.js")
---
>     script(src="./js/oauthLogin.js")
diff ./public/js.bak/login.js ./public/js/login.js
30c30
<     window.location = '/';
---
>     window.location = './';
diff ./public/js.bak/logout.js ./public/js/logout.js
3c3
<     window.location = '/login';
---
>     window.location = './login';
diff ./public/js.bak/oauthLogin.js ./public/js/oauthLogin.js
24c24
<                 window.location = '/';
---
>                 window.location = './';
27c27
<                 window.location = '/logout';
---
>                 window.location = './logout';
diff ./clientapp.bak/app.js ./clientapp/app.js
33c33
<             window.location = '/login';
---
>             window.location = './login';
117c117
<                     app.history.start({pushState: true, root: '/'});
---
>                     app.history.start({pushState: true, root: './'});
153c153
<         var url = (page.charAt(0) === '/') ? page.slice(1) : page;
---
>         var url = (page.charAt(0) === './') ? page.slice(1) : page;
diff ./clientapp.bak/router.js ./clientapp/router.js
49c49
<         window.location = '/login';
---
>         window.location = './login';

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

No branches or pull requests

1 participant