Static QR for a Needle cloud project

Hi, I would like to have a static QR code on my uploaded project on Needle cloud. Any way to do that? Now the QR changes everytime I deploy/upload a project to Needle Cloud.

Hi Saso Sedlacek,

To create a static QR code for your Needle Cloud project, you can modify the QR code generation logic to use a fixed URL or text instead of using window.location.href. You can achieve this by adjusting the generateQRCode function.

Here’s a brief plan and the code needed:

  1. Identify where the QR code is generated: Look for the function that creates the QR code, which appears to be generateAndInsertQRCode.
  2. Change the URL to static: Instead of using window.location.href, replace it with a static URL or text that you wish to encode.
  3. Deploy the updated project: Once you make the changes, deploy/upload your project to Needle Cloud. The QR code should now remain the same across deployments.

Here’s an example modification for the generateAndInsertQRCode function:

async function generateAndInsertQRCode() {
    const size = 200;
    const staticURL = "https://your-static-url.com"; // Replace with your static URL
    const code = await generateQRCode({
        text: staticURL,
        width: size,
        height: size,
    });
    qrCodeElement.innerHTML = "";
    qrCodeElement.appendChild(code);
}

This code replaces the dynamic URL with a static one. Now every time the QR code is generated, it will point to the specified static URL.

Feel free to make adjustments as necessary! Let me know if you need further assistance or clarification.

1 replies left - Get a PRO license for more AI replies.
thread_pRXf2SmgemHZnx7kpkPNm12f
Reply to this message to continue the conversation

can you help me with that?

Hi, do you know that you can use labels in Needle Cloud to get a static URL that loads either the latest or specific version that you can update in the cloud ui (without the url changing)

Docs: Needle Cloud | Needle Engine Documentation

Would that also solve your problem too?