1

I have a similar problem of this question:

This is my html:

<link rel="stylesheet" href="/css/bootstrap.min.css"></link>

and in my node app:

app.use(express.static(path.resolve(__dirname, ROOT, 'public')));

and works if I use www.mydomain.com (with proxy_pass nginx configuration)

Problem

If I want to use my app with : www.mydomain.com/app1 instead www.mydomain.com using this nginx conf:

https://stackoverflow.com/a/40985900/3957754

All works except my css. I get a 404 because html client expect a css with this path (without /app) :

www.mydomain.com/css/bootstrap.min.css

Solution 1

In order to fix this, I must to hard code app1 in css href :

 link(rel="stylesheet" href="/app1/css/bootstrap.min.css")

And a success css url is requested by html client:

www.mydomain.com/app1/css/bootstrap.min.css

Solution 2

Instead www.mydomain.com/app1, We are obliged to use subdomains like www.app1.mydomain.com.

In this case, nginx configuration is easy and our app works. But We need to create more and more subdomains :S

Attempts without success :

Question

  • Is there a way to make app independent of nginx configuration?
  • A subdomains strategy is correct?
  • Let us imagine a purchased web application to be used as www.mydomain.com/app1 because root domain www.mydomain.com is used.

    Need I to add /app1/ to all static files references of my purchased application?

Thanks in advance.

JRichardsz
  • 14,356
  • 6
  • 59
  • 94

0 Answers0