Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Commit

Permalink
feat(vhost): added vhost resolution via x-vhost request header on fas…
Browse files Browse the repository at this point in the history
…tify
  • Loading branch information
micheleriva committed Jul 29, 2021
1 parent 8cdbfeb commit bcb18e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/fastify-krabs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ export default async function krabs(
app: any,
config?: Config): Promise<void> {

const { tenants } = config ?? (await getTenantConfig());
const { tenants, enableVhostHeader } = config ?? (await getTenantConfig());

const vhostHeader = enableVhostHeader && request.headers['x-vhost'] as string;
const rawHostname = request.hostname;
const pathName = request.url;
const query = request.query;

const hostname = rawHostname.replace(/:\d+$/, '');
const tenant = findTenant(tenants, hostname);
const host = vhostHeader || hostname;
const tenant = findTenant(tenants, host);

if (!tenant) {
reply.status(500).send({
Expand Down

0 comments on commit bcb18e3

Please sign in to comment.