Generating QR-codes in Create

Hi, does anyone know if it is possible to generate QR codes in Create?

I see that there are a number of js libraries that solve this, but I don’t know how to implement them in Create.

There is a service in the Appfarm universe that will generate a QR code on the fly for you. With a specially crafted URL, you can use the image component to show it.

Example: https://resources.appfarm.io/qr/v1?url=https://appfarm.io

It is recommended to use encodeURIComponent() to encode the url-parameter:
https://resources.appfarm.io/qr/v1?url=https%3A%2F%2Fappfarm.io

Note: This QR code generator is for hyperlinks only. If you need to embed some other data, you need to use something else.

2 Likes

Hi. I get the error :
Access to XMLHttpRequest at 'https://resources.dev.appfarm.io/qr/v1?url=https%3A%2F%2Fappfarm.io' from origin 'https://mysolution-dev.appfarm.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

…when I try to create a QR code and add it to a runtime online image file.

I’ve added “https://resources.dev.appfarm.io” as a web request target and to image resource under the correct environment. What am I doing wrong?

Looks like I responded with URLs to our dev services. I corrected it now. Remove “dev.” and I think it should work.

If I remove .dev. from the URL and tick of “run on server” it works. And it’s no need to add the URL’ to the environments, it seems. :slight_smile:
image

If you don’t need to store the file data anywhere, you can use the URL directly as the source in an image component. The URL is an on-the-fly generated image of the QR code. You may need to add the domain as an allowed image source in your environment.

Since this is a trusted source for Appfarm, this should have automatically been added to the allowed sources, but I can confirm that this is not the case. I have registered a challenge on this.