Support configuring query parameters for Next.js static resources #82734
windwalker
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Background
Our team maintains multiple Next.js services, each corresponding to a product, e.g. /shopping, /cart, /search. All the static files generated from these services are deployed into a shared directory in order to maximize caching efficiency.
We need to track the CDN cost of each service. To do so, we must identify which product (service) initiates each static asset request. For example, if [hash].js is requested while serving /shopping.html, we want to know that the request originated from the "shopping" service.
Since the CDN host is different from the main site, we cannot rely on the Referer header to distinguish the source of the request.
We would like a way to append metadata (such as a query parameter or a request header) to static asset requests. For example:
'[hash.js]?from=shopping'
This would allow us to attribute CDN usage back to the correct service.
Is this possible with the current Next.js version? If not, would you please evaluate the feasibility of supporting this feature?
Proposal
I would like to propose a configuration option similar to assetPrefix, which could be called assetQueryParams:
Since each product is served by an independent Next.js service in our team, this feature would make it straightforward to automatically append the service identifier as a query parameter to all asset requests.
Beta Was this translation helpful? Give feedback.
All reactions