Skip to content

Easier CORS settings / requestInitGenerator loop #24

Open
@joepio

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions