lwsjs / local-web-server

A lean, modular web server for rapid full-stack development.
MIT License
1.23k stars 87 forks source link

Spa per folder #156

Closed WORMSS closed 4 years ago

WORMSS commented 4 years ago

Is it possible to have different spa's in different folders?

Eg

/test1/ is one self contained SPA
/test2/ is another self contained SPA

They are not linked in any way what so ever.

75lb commented 4 years ago

It's not currently possible with the built-in lws-spa module but you could fork that project and modify it to your taste.. there's a description of how to use and create middleware here,

Or, you could launch two separate ws servers - one for each SPA.. This may require you to reorganise your project slightly but it would be worth it, with better separation/re-use between the two projects.

The complexity in what you are requesting comes from the SPA redirect rules. E.g. if a user requests the path /user/1 then should ws redirect that request to /test1/spa.html or /test2/spa.html?

WORMSS commented 4 years ago

I would expect /user/1 to 404

But /test1/user/1 to go to /test1/index.html And /test2/user/1 to go to /test2/index.html

The multi/server was something I had considered but didn't know how well that would work with https certs. (New Territories for me) And even the best way to proxy /test1/user/1 goes to localhost:4331/user/1 And /test2/user/1 goes to localhost:4332/user/1

I will look into forking spa and quickly jump to redirect. If I fail at redirect i will try harder at tweaking spa.

75lb commented 4 years ago

The multi/server was something I had considered but didn't know how well that would work with https certs.

ws --https will run on multiple ports..

/test1/user/1 goes to localhost:4331/user/1 And /test2/user/1 goes to localhost:4332/user/1

Maybe use lws-redirect for creating 302 Redirect responses if you need to direct the user to different servers..

WORMSS commented 4 years ago

I don't plan on making the other servers public if I go down the multiserver way. I want it to look like 1 server from the outside. So will prob proxy those folders to the internal servers.

damianobarbati commented 3 years ago

@WORMSS did you find solution to this without writing tons of other files?