Skip to content
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

Possiblity to have assetUrlPrefix factory #766

Closed
chladog opened this issue Mar 15, 2021 · 1 comment
Closed

Possiblity to have assetUrlPrefix factory #766

chladog opened this issue Mar 15, 2021 · 1 comment

Comments

@chladog
Copy link
Contributor

chladog commented Mar 15, 2021

Is your feature request related to a problem? Please describe.
We have single backend for multiple UIs on different domains. The automatic resolution of asset URL doesn't work for us in a way we would like and we need more control over it.
assetUrlPrefix option worked for us when having single domain, but now when we have multiple domains we need to be able to resolve the URL root on the fly - e.g. from req host property.

Describe the solution you'd like
assetUrlPrefix to allow custom function that would have RequestContext as a parameter and return type of string. With such functionality we will be able to serve media files with same domain as UI, or any other dynamically resolved URL prefix.

Describe alternatives you've considered
JS string replace() method on already resolved media url.

Additional context
v1.0-beta.3

@michaelbromley
Copy link
Member

This is a good idea and can be implemented without a breaking change.

assetUrlPrefix to allow custom function that would have RequestContext as a parameter and return type of string

We can definitely pass the Express req object in, and I'll have to check whether it is possible to also supply the RequestContext. The reason is that this function will be executed in the Apollo Server layer, outside the NestJS context. But since the RequestContext is internally stored as a property on the req object it should be possible to fish it out and pass to this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants