-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a .host() method to set a host other than 127.0.0.1 #297
Conversation
yes yes yes |
If somebody looks for an opportunity virtual hosts testing. My solution is below. function createVhostTester(app, vhost) {
const real = supertest(app);
const proxy = {};
Object.keys(real).forEach(methodName => {
proxy[methodName] = function() {
return real[methodName]
.apply(real, arguments)
.set('host', vhost);
}
});
return proxy;
}
var api = createVhostTester(appInstance, 'api.example.com');
var appTest = createVhostTester(appInstance, 'app.example.com'); |
@mikelax this PR could fix problems with IP V6 as well since one could pass ::1 as address 👍 |
Hello! Is it likely this will get merged? |
Nice work! I would also love for this to be a feature in supertest 👍 |
This is a great feature needed. Please consider merging. Ping. |
@shults your solution worked perfectly for me :) |
Will this PR ever be considered to be merged? It's 1.5 years old now ..... |
+1 |
1 similar comment
+1 |
This allows you to set the server hostname before making a request. If no hostname is set then it defaults to 127.0.0.1
@mikelax I fixed the conflicts and build errors, can this be merged? |
+1 |
1 similar comment
+1 |
guys, any update on this? Would be very great to see this added soon... |
I believe you can do this using the example below:
Express 4 then shows req.subdomains as ['api']. |
+1 |
@lauzierj many thanks for providing that example, worked nicely. So many people waiting for it and it got already added. No idea, maybe not documented? At least I had not found anything at the time I was looking for that feature. |
+1 |
Thank you for your contributions. |
I merge it into |
This allows you to set the server hostname before making a
request. If no hostname is set then it defaults to 127.0.0.1