fix marbas proxy
This commit is contained in:
@@ -6,15 +6,18 @@ server {
|
||||
location / {
|
||||
try_files $uri $uri/ $uri.html /index.html;
|
||||
}
|
||||
location /api/ {
|
||||
proxy_pass https://${API_URL}/;
|
||||
location /marbas/ {
|
||||
proxy_pass https://${MARBAS_URL}/;
|
||||
proxy_http_version 1.1;
|
||||
rewrite /api/(.*) /$1 break;
|
||||
rewrite /marbas/(.*) /$1 break;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_set_header Host "${API_URL}";
|
||||
proxy_set_header Host "${MARBAS_URL}";
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header Accept-Encoding "";
|
||||
sub_filter 'https://${API_URL}/' '/appi/';
|
||||
sub_filter 'https://${MARBAS_URL}/' '/marbas/';
|
||||
sub_filter 'http://${MARBAS_URL}/' '/marbas/';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
location /pocketbase/ {
|
||||
proxy_pass https://${POCKET_BASE_URL}/;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { apiAxiosInstance } from "@/service";
|
||||
import { marbasAxiosInstance } from "@/service";
|
||||
|
||||
export type MarketType = {
|
||||
id: number;
|
||||
@@ -18,9 +18,9 @@ export const getMarketTypes = async (types: (string | number)[]): Promise<Market
|
||||
if (types.length === 0) {
|
||||
return [];
|
||||
} else if (types.length === 1 && typeof types[0] === "number") {
|
||||
return [(await apiAxiosInstance.get<MarketType>(`/sde/types/${types[0]}/`)).data];
|
||||
return [(await marbasAxiosInstance.get<MarketType>(`/sde/types/${types[0]}/`)).data];
|
||||
}
|
||||
return (await apiAxiosInstance.post<MarketType[]>("/api/types/search", types.map(t => {
|
||||
return (await marbasAxiosInstance.post<MarketType[]>("/api/types/search", types.map(t => {
|
||||
if (typeof t === "number") {
|
||||
return { id: t };
|
||||
} else {
|
||||
@@ -49,7 +49,7 @@ const blueprintMarketGrous = [ // TODO add all groups
|
||||
]
|
||||
|
||||
export const searchMarketTypes = async (search: string): Promise<MarketType[]> => {
|
||||
return (await apiAxiosInstance.post<MarketType[]>("/api/types/search", [{
|
||||
return (await marbasAxiosInstance.post<MarketType[]>("/api/types/search", [{
|
||||
name__icontains: search,
|
||||
marketgroup_id___not: null,
|
||||
marketgroup_id__in___not: blueprintMarketGrous,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { apiAxiosInstance } from "@/service";
|
||||
import { marbasAxiosInstance } from "@/service";
|
||||
|
||||
export type ReprocessItemValues = {
|
||||
typeID: number;
|
||||
@@ -22,7 +22,7 @@ export const reprocess = async (items: string, minerals: string, efficiency?: nu
|
||||
};
|
||||
const source = JSON.stringify(sourceJson);
|
||||
|
||||
const response = await apiAxiosInstance.post('/reprocess/', source, {params: {efficiency: efficiency ?? 0.55}});
|
||||
const response = await marbasAxiosInstance.post('/reprocess/', source, {params: {efficiency: efficiency ?? 0.55}});
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -12,20 +12,26 @@ const logResource = (a: AxiosInstance) => {
|
||||
});
|
||||
}
|
||||
|
||||
export const apiAxiosInstance = axios.create({
|
||||
baseURL: '/api/',
|
||||
export const marbasAxiosInstance = axios.create({
|
||||
baseURL: '/marbas/',
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
})
|
||||
logResource(apiAxiosInstance)
|
||||
apiAxiosInstance.interceptors.response.use(async r => {
|
||||
marbasAxiosInstance.interceptors.request.use(r => {
|
||||
if (!r.params?.page_size) {
|
||||
r.params = { ...r.params, page_size: 250 };
|
||||
}
|
||||
return r;
|
||||
})
|
||||
logResource(marbasAxiosInstance)
|
||||
marbasAxiosInstance.interceptors.response.use(async r => {
|
||||
const next = r.data?.next;
|
||||
let results = r.data?.results;
|
||||
|
||||
if (next) {
|
||||
results = results.concat((await apiAxiosInstance.request({
|
||||
results = results.concat((await marbasAxiosInstance.request({
|
||||
...r.config,
|
||||
url: next,
|
||||
baseURL: '',
|
||||
|
||||
@@ -22,11 +22,11 @@ export default defineConfig(({ mode }) => {
|
||||
usePolling: true
|
||||
},
|
||||
proxy: {
|
||||
'/api/': {
|
||||
target: env.API_URL,
|
||||
'/marbas/': {
|
||||
target: env.MARBAS_URL,
|
||||
changeOrigin: true,
|
||||
followRedirects: true,
|
||||
rewrite: path => path.replace(/^\/api/, ''),
|
||||
rewrite: path => path.replace(/^\/marbas/, ''),
|
||||
selfHandleResponse: true,
|
||||
configure: proxy => {
|
||||
proxy.on('proxyRes', (proxyRes, req, res) => {
|
||||
@@ -38,7 +38,7 @@ export default defineConfig(({ mode }) => {
|
||||
const encoding = proxyRes.headers["content-encoding"];
|
||||
const relace = (b: Buffer) => {
|
||||
let remoteBody = b.toString();
|
||||
const modifiedBody = remoteBody.replace(env.API_URL, '/api/');
|
||||
const modifiedBody = remoteBody.replace(env.MARBAS_URL, '/marbas/');
|
||||
|
||||
res.write(modifiedBody);
|
||||
res.end();
|
||||
|
||||
Reference in New Issue
Block a user