vast-engineering / express-vhost Goto Github PK
View Code? Open in Web Editor NEWImproves on express.js middleware for vhost by avoiding expensive regex chains. This will perform better and scale more than connect vhost.
Improves on express.js middleware for vhost by avoiding expensive regex chains. This will perform better and scale more than connect vhost.
I've seen some solutions online for setting up subdomains, and most require creating a separate folder for the other servers. For example, so that, m.soundcloud.com
actually launches a different app than soundcloud.com
.
Does this plugin get around this?
Hi, when I follow your tutorial building the vhost, I encounter a error at index.js:4:
^
SyntaxError: Unexpected token <
How should I solve this problem?Thanks~
This is the place in the code that causes breakage:
if (!server){
server = hostDictionary['*' + host.substr(host.indexOf('.'))];
}
No doubt implemented this way to avoid huge nasty regexes but this will not work because it will cull the entire domain if the hostname doesn't have a sub-domain like www
.
To be specific: Given a hostname such as site.com
this will attempt to fetch from the dict a value *.com
, which will fail.
Chief among various solutions/workarounds is having an appropriate DNS CNAME entry to forward the naked comain to www
subdomain. But this is definitely a bug in my eyes to not deal with this particular situation. As for the various complexities involved with getting a website working properly with a naked domain, that's out of the scope of this discussion, I reckon.
FWIW, I experienced the same sort of issue with the other vhost
middleware, so their fancy regexes apparently aren't solving this issue either, though I haven't actually looked into what the deal is there. But just looking at the source, I'd much rather use express-vhost
anyway.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.