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