Skip to content

Change http-proxy & types into dependencies #17

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

Merged
merged 1 commit into from
Jan 30, 2021

Conversation

larrifax
Copy link
Contributor

@larrifax larrifax commented Jan 27, 2021

I believe these dependencies needs to lie in the dependencies array so that they're accessible to consumers of your library.

Installing version 1.0.8 yields Typescript errors whenever I try to add any NextHttpProxyMiddlewareOptions originating from @types/http-proxy, e.g.:

import { NextApiRequest, NextApiResponse } from "next";
import proxy from "next-http-proxy-middleware";

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
  return proxy(req, res, {
    target: "http://some-target.url"
  });
};

export default handler;

Error:

Argument of type '{ target: string | undefined; }' is not assignable to parameter of type 'NextHttpProxyMiddlewareOptions'.
  Object literal may only specify known properties, and 'target' does not exist in type 'NextHttpProxyMiddlewareOptions'.

The same version also yields runtime errors, since http-proxy isn't installed: Error: Cannot find module 'http-proxy'.

@stegano stegano merged commit e311e7b into stegano:master Jan 30, 2021
@stegano
Copy link
Owner

stegano commented Jan 30, 2021

Hi @larrifax
Thanks for your PR!
I will release the modified code as a hotfix

@stegano
Copy link
Owner

stegano commented Jan 30, 2021

@all-contributors please add @larrifax for bug

Now released on npm.
Thanks for fixing the bug 😀

@allcontributors
Copy link
Contributor

@stegano

This project's configuration file has malformed JSON: .all-contributorsrc. Error:: Unexpected token } in JSON at position 576

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.

2 participants