Replies: 7 comments
-
What kind of example are you looking for? |
Beta Was this translation helpful? Give feedback.
-
Yes, just something simple.
The equivalent in typescript would be enough for us. |
Beta Was this translation helpful? Give feedback.
-
Would something like this help? import * as express from 'express';
import * as proxy from 'http-proxy-middleware';
const app = express();
app.use(proxy({
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true
}))
app.listen(3000);
// http://localhost:3000/users |
Beta Was this translation helpful? Give feedback.
-
Hi, this doesn't work for me, I am using create-react-app, and it does not use express. To create a new react app with typescript, do this:
(see) https://facebook.github.io/create-react-app/docs/adding-typescript So, how would you add the proxy into a hello world app like this? |
Beta Was this translation helpful? Give feedback.
-
I'm not a React user. If I take your example and make it Typescript it would look like this: import * as proxy from 'http-proxy-middleware';
export default function(app) {
app.use(
proxy('/api', {
target: process.env.REACT_APP_PROXY,
changeOrigin: true,
secure: false
})
)
}; Think it would be better to ask this question on their issue tracker. Maybe this is something they are missing in their documentation... |
Beta Was this translation helpful? Give feedback.
-
@jmcginty did you find a way to do it in react typescript? |
Beta Was this translation helpful? Give feedback.
-
facebook/create-react-app#8273 |
Beta Was this translation helpful? Give feedback.
-
Is this a feature request?
Yes
It would be great to have a simple example in typescript
Thanks !
James
Beta Was this translation helpful? Give feedback.
All reactions