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

Easier CORS settings / requestInitGenerator loop #24

Open
joepio opened this issue Jun 14, 2021 · 0 comments
Open

Easier CORS settings / requestInitGenerator loop #24

joepio opened this issue Jun 14, 2021 · 0 comments

Comments

@joepio
Copy link

joepio commented Jun 14, 2021

I'd like to be able to fetch URLs from a different domain, which means adding some headers to each request.

I've done this in two projects at this moment: openbesluitvorming and link-solid-boilerplate. In both, the code looks like this:

  const store = new RDFStore()
  const storeOptions = {
    report: handle,
    // This part is for setting CORS.
    api: new DataProcessor({
      requestInitGenerator: new RequestInitGenerator({
        credentials: "omit",
        csrfFieldName: "csrf-token",
        mode: "cors",
        xRequestedWith: "XMLHttpRequest"
      }),
      report: handle,
      store,
    })
   };

it works, but it feel unintuitive, and passing a new RDFStore doesn't feel necessary.
When I change api to apiOpts, like so:

  apiOpts: {
    requestInitGenerator: new RequestInitGenerator({
      credentials: "omit",
      csrfFieldName: "csrf-token",
      mode: "cors",
      xRequestedWith: "XMLHttpRequest"
    }),
  }

The fetcher is looping, fetching the same thing over and over again.

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