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

Access-Control-Allow-Origin CORS policy: #143

Open
ArnurArykbaev opened this issue Jan 23, 2023 · 1 comment
Open

Access-Control-Allow-Origin CORS policy: #143

ArnurArykbaev opened this issue Jan 23, 2023 · 1 comment

Comments

@ArnurArykbaev
Copy link

ArnurArykbaev commented Jan 23, 2023

Access to image at 'someMyURL' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

The image appears in img tag, but in vue-qr it gives an error

@Vitomir2
Copy link

Vitomir2 commented Jan 23, 2023

@ArnurArykbaev , I also was facing this problem and I made a workaround by opening the file, then converting it to base64 and put that in the logoSrc. I do not have read file thing anymore, because I load the image from user input (image uploader), but this is my converter to base64:

export function convertFileToBase64(fileObject) {
	return new Promise(async (resolve, reject) => {
		try {
			const reader = new FileReader()
			reader.readAsDataURL(fileObject)
			reader.onloadend = function() {
				const base64data = reader.result
				resolve(base64data)
			}
		} catch (error) {
			reject(error)
		}
	})
}

However, if someone knows how to solve this error, and not just workaround, I will be happy to hear that. I have some cases where the image will be taken form AWS S3 Bucket, which gives me exactly the same error when running it locally.

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

No branches or pull requests

2 participants