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

$removeparam causes that preflight request is blocked #1632

Closed
AdamWr opened this issue May 6, 2022 · 1 comment
Closed

$removeparam causes that preflight request is blocked #1632

AdamWr opened this issue May 6, 2022 · 1 comment

Comments

@AdamWr
Copy link
Member

AdamWr commented May 6, 2022

Steps to reproduce

  1. Add this rule:
||api.github.com^$removeparam=abc,xmlhttprequest
  1. Go to - https://example.org/
  2. Run this script in console:
(() => {
  const myHeaders = new Headers();
  myHeaders.append('Content-Type', 'application/zip');
  const myRequest = new Request('https://api.github.com/?abc=test', {
    method: 'GET',
    headers: myHeaders,
    mode: 'cors'
  });
  fetch(myRequest).then(response => {
    return response.text();
  }).then(text => {
    console.log(text);
  }).catch(e => {
    console.log('Error: ', e);
  });
})();

If $removeparam rule is added then request is blocked.

Access to fetch at 'https://api.github.com/?abc=test' from origin 'https://example.org' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
Screenshot

image

If rule is disabled then request is not blocked.

Screenshot

image

I'm not sure if it's a bug or CoreLibs limitation, but it seems that this issue doesn't occur with extension.

@sfionov
Copy link
Member

sfionov commented May 6, 2022

Yes, we shouldn't redirect preflights but strip parameters on the fly.

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

No branches or pull requests

4 participants