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

add fetch options #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add fetch options #13

wants to merge 1 commit into from

Conversation

gormonn
Copy link

@gormonn gormonn commented Sep 22, 2020

add fetch options to pass headers

In some cases we need to pass api-key or something else.

For example:

app.get("/WebClient/*", 
  async (req, res, next) => {
    res.locals.fetchUrl = `http://someapi.ru/WebClient/${req.params[0]}?${encodeQuery(req.query)}`;
    res.locals.options = { headers: req.headers }
    next();
  },
  fileCacheMiddleware({ cacheDir, maxSize: 10 * 1024 * 1024 * 1024 * 1024 }),
  (req, res) => {
    res.set({
      "Content-Type": res.locals.contentType,
      "Content-Length": res.locals.contentLength
    });
    res.end(res.locals.buffer, "binary");
  }
);

add fetch options to pass headers
@julianrubisch
Copy link
Owner

Great, thanks!

I haven't looked in here for a while, and just to make sure we don't break anything - could you add a test?

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

Successfully merging this pull request may close these issues.

None yet

2 participants