Replies: 2 comments
-
I have a similar problem with http-proxy-middleware. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Some assumptions:
Some assumptions:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
src/setupProxy.ts
import express from 'express';
import {createProxyMiddleware} from 'http-proxy-middleware';
const app = express();
app.use('/registration-api/**', createProxyMiddleware({target: 'http://localhost:8710', changeOrigin: true}));
app.listen(3000);
config axios
export const http = axios.create({
baseURL: baseUrl()
});
where baseUrl use for context path
export function baseUrl() {
const applicationUrl = document.head.querySelector('meta[name=application-url]');
const baseUrl = applicationUrl ? applicationUrl.getAttribute('content') : '/';
return baseUrl == null ? '/' : baseUrl;
}
api
export function registration(values: RegistrationFormData): Promise<AxiosResponse> {
return http.post('/registration-api/registration', values);
}
api call result
POST http://localhost:3000/registration-api/registration 404 (Not Found)
What am I doing wrong ?
Beta Was this translation helpful? Give feedback.
All reactions