How to configure js path

39 views
Skip to first unread message

and...@gmail.com

unread,
May 12, 2014, 11:08:43 PM5/12/14
to tot...@googlegroups.com
Hi!

My app URL is something like this:
http://my-domain.com/my-app/

My controller is working and it's configured like this:
framework.route('/my-app/', view_home);

My homepage.html is also working. The tag @{js('my-script.min.js')} outputs:
<script src="/my-app/js/my-script.min.js" type="text/javascript"></script>

I have a config-debug file with this content:
static-url : /my-app/
static-url-js : /my-app/js/

The problem: my server gives me 404 when I try to GET http://my-domain.com/my-app/js/my-script.min.js

I need to GET my JS files under http://my-domain.com/my-app/js

I don't know why, but I can GET this way: http://localhost:8000/js/my-script.min.js

I don't know if this is a totaljs config issue, or some kind of nginx config issue.

Could anybody help me, please?

Peter Širka

unread,
May 13, 2014, 1:42:49 AM5/13/14
to tot...@googlegroups.com
Hi André,
I must see your nginx configuration.

Scripts:
- you must create /my-app/js/ directory. Config: static-url-js is only for "routing" in views. So the request is routed into the: http://my-domain.com/my-apps/js/my-script.min.js and this file must really exists.

A potential problem:
- every total.js app must have an own hostname. So, you can't run more apps in one domain, example:


Thanks :-)

André Gomes

unread,
May 13, 2014, 5:23:21 AM5/13/14
to tot...@googlegroups.com
I don't have the nginx config right now, but I'll post it here soon.

I didn't know two totaljs apps cannot share the same domain. That's exactly what I want to do. It's not a big deal, because I can change it to http://my-app.my-domain.com/

It's not perfect, but it's fine.

Thanks!

Peter Širka

unread,
May 13, 2014, 4:49:25 PM5/13/14
to tot...@googlegroups.com
Theoretically it is possible add this feature. I'll see on it.
Thanks.

But it is not a standard.
Thanks :-)

Peter Širka

unread,
May 13, 2014, 4:56:59 PM5/13/14
to tot...@googlegroups.com
André this must work theroetically, please try it:

You must create a full exists path for the scripts, example:
/your-app-directory/public/my-app/js/my-script.min.js

So this must work:

Please give me a feedback.

André Gomes

unread,
May 13, 2014, 8:32:57 PM5/13/14
to tot...@googlegroups.com
I'll try it and feedback you as soon as possible.

Thanks

André Gomes

unread,
May 13, 2014, 10:08:19 PM5/13/14
to tot...@googlegroups.com
You are right! That worked 100%

Here is the nginx config:

server {
        listen
80;
        server_name
my-domain.com;
        charset utf
-8;

       
# my personal homepage (totaljs too)
        location
/ {
                proxy_pass http
://127.0.0.1:8001;
                proxy_http_version
1.1;
                proxy_set_header
Upgrade $http_upgrade;
                proxy_set_header
Connection 'upgrade';
                proxy_set_header
Host $host;
                proxy_cache_bypass $http_upgrade
;
       
}

       
# my awesome app (that's the relevant part)
        location
/my-app/ {
                proxy_pass http
://127.0.0.1:8000;
                proxy_http_version
1.1;
                proxy_set_header
Upgrade $http_upgrade;
                proxy_set_header
Connection 'upgrade';
                proxy_set_header
Host $host;
                proxy_cache_bypass $http_upgrade
;
       
}
}

However, as you said, we must have only one totaljs app per domain. So, I have moved to http://my-app.my-domain.com/ instead of http://my-domain.com/my-app/

Thank you.
Reply all
Reply to author
Forward
0 new messages