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

Type error: This expression is not callable. #7

Closed
joegyoung opened this issue Nov 17, 2020 · 2 comments
Closed

Type error: This expression is not callable. #7

joegyoung opened this issue Nov 17, 2020 · 2 comments

Comments

@joegyoung
Copy link

I am getting error with my page

./pages/api/[...all].ts:13:10
Type error: This expression is not callable.
  Type 'typeof import("/Users/joeyoung/_WORKING/joegyoung/node_modules/next-http-proxy-middleware/src/index")' has no call signatures.

  11 | 		} = req;
  12 | 
> 13 | 		return httpProxyMiddleware(req, res, {
     | 		       ^
  14 | 			// You can use the `http-proxy` option
  15 | 			target: `http://localhost:9000/.netlify/functions/${all}`,
  16 | 			pathRewrite: {
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is the source

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

const isDevelopment = process.env.NODE_ENV === "development";
const isProduction = process.env.NODE_ENV === "production";

export default (req: NextApiRequest, res: NextApiResponse) => {
	if (isDevelopment) {
		const {
			query: { all },
		} = req;

		return httpProxyMiddleware(req, res, {
			// You can use the `http-proxy` option
			target: `http://localhost:9000/.netlify/functions/${all}`,
			pathRewrite: {
				"^/api+": "",
			},
		});
	} else {
		res.status(404).send(null);
	}
};

What am I needing to do?

@joegyoung
Copy link
Author

I have fixed my issue by using "iwatakeshi/next-http-proxy-middleware"

@stegano
Copy link
Owner

stegano commented Nov 18, 2020

Hi, @joegyoung
Thanks for your reporting
I'll fix it as soon as possible.

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

2 participants