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

Conflict with webpack and ember-auto-import v2 in an emberjs project #357

Open
les2 opened this issue Oct 26, 2022 · 0 comments
Open

Conflict with webpack and ember-auto-import v2 in an emberjs project #357

les2 opened this issue Oct 26, 2022 · 0 comments

Comments

@les2
Copy link

les2 commented Oct 26, 2022

In an EmberJS project, I upgraded to ember-auto-import v2 and i get a single test failure with a webpack related exception. I'm wondering if there could be a conflict between this library (pretender) and webpack?

Pretender intercepted GET webpack://__ember_auto_import__/./node_modules/fake-xml-http-request/src/fake-xml-http-request.js? but no handler was defined for this type of request

Other uses of Pretender in the tests are working fine. There's nothing unusual to my eyes about how it's being used here.

I have the usual passthrough configured like this:

    const server = new Pretender();
    server.prepareHeaders = function(headers) {
      headers[ 'content-type' ] = 'application/vnd.api+json';
      return headers;
    };
    server.get('/**', server.passthrough);

pretender version is 3.4.7
ember is 3.12
ember-auto-import is 2.4.3

Update

I added a handler for unhandled requests like this:

    server.unhandledRequest = function(verb, path, request) {
      if (path.startsWith('webpack://')) {
        request.passthrough();
      } else {
        console.error(`Unhandled request: ${verb} ${path}`);
        throw new Error(`Unhandled request: ${verb} ${path}`);
      }
    };

which results in this error being logged:

'webpack://__ember_auto_import__/./node_modules/fake-xml-http-request/src/fake-xml-http-request.js?' 
from origin 'http://localhost:7357' has been blocked by CORS policy: 
Cross origin requests are only supported for protocol schemes: http, data, isolated-app, 
chrome-extension, chrome, https, chrome-untrusted.
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

1 participant