Importance of query params added by JS SDK-- is it OK to remove?

Christian
Christian Member Posts: 1

The following code (in Node.js / React) in some cases produces URLs with query parameters appended to the URL:

import { Cloudinary } from "@cloudinary/url-gen";

const cld = new Cloudinary({
  cloud: {
    cloudName: '__redacted__'
  },
});

const url = cld
  .image('ID')
  .quality("auto")
  .resize(fit(size))
  .delivery(format(isSvg ? svg() : auto()))
  .toURL();

The added URL parameters are problematic for server-side rendering, as the client and server need to have identical HTML. For now I'm removing the query params like so:

const urlObject = new URL(url);

urlObject.search = "";

return urlObject.href;

So my two questions are:

  • What is the significance of the randomized query params? Is it for cache busting?
  • What are the implications of removing the query params as shown in the code above-- and is there a built-in way to disable query param generation?

Answers

  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 170 admin

    Hi there,

    Thanks for reaching out.

    This is due to an analytics parameter that is part of the URL config. URLs generated by the SDK include an appended query parameter that passes SDK usage information. This parameter is true by default. But you can change that Boolean to false.

    You can reference the documentation here for additional information on those configuration parameters:
    https://cloudinary.com/documentation/cloudinary_sdks#configuration_parameters

    I hope this helps. If you have any questions, do not hesitate to ask.

    Kind regards,

    Tia

    Helpful Links For You
    💬 Share questions, connect with other users in our Cloudinary Community forums and Discord server!
    🧑‍🎓 Join our Cloudinary Academy for free courses, workshops and other educational resources.
    📄 Read our documentation for in-depth details on Cloudinary product features and capabilities
    📰 Check out the Cloudinary blog for the latest company news and insights