needle-innovision / nestjs-tenancy

Multi-tenancy approach for nestjs - currently supported only for mongodb with mongoose
MIT License
187 stars 58 forks source link

Subdomains is not being identified correctly #3

Closed gapinto closed 4 years ago

gapinto commented 4 years ago

For example:

I'm using postman to simulate a subdomain: gap.tenancy.com.br The subdomain returned is tenancy, where the correct subdomain should be gap.

I have edited my etc/hosts to something like this:

127.0.0.1 gap.tenancy.com.br

https://github.com/needle-innovision/nestjs-tenancy/blob/117280bb2ce508a0f1a4336715c78ffe093522ec/lib/tenancy-core.module.ts#L176

sandeepsuvit commented 4 years ago

Hi @gapinto

Can you try setting the configuration isTenantFromSubdomain like below when using subdomain based tenant

TenancyModule.forRoot({
        // This will allow the library to extract the subdomain as tenant id
        isTenantFromSubdomain: true,
        options: () => {},
        uri: (tenantId: string) => `mongodb://localhost/test-tenant-${tenantId}`,
    }),

If yes can you provide me the configurations that you are using for postman to replicate testing on my end.

sandeepsuvit commented 4 years ago

@gapinto i have published a new version v1.0.9 with a small fix for multi-level subdomains. Please let me know if that fixes your issue.

sandeepsuvit commented 4 years ago

@gapinto can you confirm if this is working for you so that i can close this issue pls?

sandeepsuvit commented 4 years ago

Closing this issue as there was no followup. Hope the new version addresses the fix.