Git Product home page Git Product logo

subdomain's People

Contributors

bitdeli-chef avatar codephobia avatar edwardhotchkiss avatar jeddawson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

subdomain's Issues

Headers sending more than once.

I don't know if this is a bug or just something happening with the way I have implemented the module but it looks like the headers can get sent more than once when forcing no www when you try to go to www.domain.com. It looks like this is due to line 25 when it i redirecting and then calling next(). Thinking this would be fixed by changing the code to use a return on the redirect and removing the next() call like so:

// remove 'www' prefix from URL? (tacky, right?)
if (options.removeWWW === true) {
  if (/^www/.test(host)){
    return response.redirect(protocol + '://' + host.replace(/^www\./, '') + request.url);
    //next();
  };
};

Still work in Express 3.x?

I'm giving the plugin a tire kick and it doesn't seem to work (for localhost). I have the subdomain added to my /etc/hosts file.

contact.localhost:3000 just routes to '/' ignoring the middleware I gave it to follow.

This is my code:

...

var subdomain = require('subdomain');
app.use(subdomain({ base : 'localhost', removeWWW : true }));
app.get('/subdomain/contact/', contactController.getContact);

...

Thanks in advance.

Router

I'm trying to use this inside a router but doesn't seems to work.

Can you provide a working example?

Thanks

req.headers.host not always available

Even though the 'host' header is mandatory, if your server is being attacked maliciously that header isn't always set. So we should check if it's truthy before using it.

Otherwise this is the error:

TypeError: Cannot call method 'match' of undefined
at /usr/src/project/node_modules/subdomain/lib/subdomain.js:41:26

TypeError: Cannot call method 'match' of undefined

Any thoughts on this? Am I the only one that's seeing this?
This is being caught in: config/routes.js#completeRegistration

slide-server-server-21 (err): TypeError: Cannot call method 'match' of undefined
slide-server-server-21 (err): at Layer.handle (/home/gmike/projects/slide-server/src/server2/node_modules/subdomain/lib/subdomain.js:41:26)
slide-server-server-21 (err): at trim_prefix (/home/gmike/projects/slide-server/src/server2/node_modules/express/lib/router/index.js:226:17)
slide-server-server-21 (err): at c (/home/gmike/projects/slide-server/src/server2/node_modules/express/lib/router/index.js:198:9)
slide-server-server-21 (err): at Function.proto.process_params (/home/gmike/projects/slide-server/src/server2/node_modules/express/lib/router/index.js:251:12)
slide-server-server-21 (err): at next (/home/gmike/projects/slide-server/src/server2/node_modules/express/lib/router/index.js:189:19)
slide-server-server-21 (err): at Layer.methodOverride as handle
slide-server-server-21 (err): at trim_prefix (/home/gmike/projects/slide-server/src/server2/node_modules/express/lib/router/index.js:226:17)
slide-server-server-21 (err): at c (/home/gmike/projects/slide-server/src/server2/node_modules/express/lib/router/index.js:198:9)
slide-server-server-21 (err): at Function.proto.process_params (/home/gmike/projects/slide-server/src/server2/node_modules/express/lib/router/index.js:251:12)
slide-server-server-21 (err): at next (/home/gmike/projects/slide-server/src/server2/node_modules/express/lib/router/index.js:189:19)

Mapping subdomains to public directory

Hi,

I can't seem to access my public directory when the URL includes the subdomain. For example,

http://sub.host.com/css/style.css

won't route me to my public directory. So right now I've been using middleware to redirect. in my app.js i have:

app.use(express.static(__dirname + '/public'));

DNS issue

Hi there,

thanks for the plugin :) I am trying it out, but while I can get it to work on localhost I can't get it to work on a hosted domain.

server DNS address could not be found

I use an env variable to set-up the base domain like so: base: process.env.DOMAIN || 'localhost'

Any idea how to solve this issue?

Koa support

Hi, I just started using Koa.js for testing purposes but couldn't find a way to test sub-domains so I ported the code for Koa. If interested, I created a gist here. It seems to work as the original in my mocha tests but I cannot guarantee. Anyways, happy coding!

Cant Use Ip

Hi, I'm having an issue where I cant use an IP address for my Staging.

My staging site only has an IP and not a domain name.

Any suggestions?

using localhost doesn't work

Regex in Subdomain

Is it possible to use regex in subdomain?

Example:

subdomain = '/subdomain/blog';
router.get(new RegExp(subdomain.replace(/\//g, '\\/') + "\\/((test|tester|tests)\\/?)$"), function(req, res) {
    res.send('hello world');
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.