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

xhr request fails in iframe #20

Open
hlolli opened this issue Aug 8, 2020 · 1 comment
Open

xhr request fails in iframe #20

hlolli opened this issue Aug 8, 2020 · 1 comment

Comments

@hlolli
Copy link

hlolli commented Aug 8, 2020

Thanks for the best logging library out there!

One glitch I bumped into, when calling log.info from inside iframe, an iframe which I instantiate as BlobURL.

The call would be here

            try {
                if (isBrowser) {

                    let xhr = new XMLHttpRequest ()

                        xhr.open ('GET', path, false /* SYNCHRONOUS XHR FTW :) */)
                        xhr.send (null)

                    this.text = xhr.responseText

                } else {

The error in Chrome

6cb0327a-6bb3-4ae6-87cf-91d6c71c5e80:5667 GET blob:http://localhost:3000/4c010b36-0716-4494-8acf-ddb045159385/ net::ERR_FILE_NOT_FOUND

The iframe I create btw like this

    const iFrameHtml = [
      `<!doctype html>`,
      `<html lang="en">`,
      `<head>`,
      `</head>`,
      `<body>`,
      `<script type="text/javascript" src="${ScriptProcessorNodeWorker()}"></script>`,
      `</body>`,
    ].join('\n');

    const iFrameBlob = new Blob([iFrameHtml], { type: 'text/html' });
    const iFrame = document.createElement('iframe');
    iFrame.src = URL.createObjectURL(iFrameBlob);
    iFrame.sandbox.add('allow-scripts', 'allow-same-origin');
    document.body.appendChild(iFrame);
@xpl
Copy link
Owner

xpl commented Aug 9, 2020

I'm not sure yet what exactly is happening, but as a quick workaround you can try disabling location tags, so it won't try to fetch the page source:

log = ololog.configure ({ locate: false })

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