Add API_HOST to upload/download

This commit is contained in:
Kieran 2022-02-26 12:44:29 +00:00
parent d82c43bb3e
commit bd2464bd47
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 9 additions and 5 deletions

View File

@ -1,7 +1,5 @@
import {useSelector} from "react-redux";
import preval from "preval.macro";
const ApiHost = preval`module.exports = process.env.API_HOST || '';`;
import {ApiHost} from "./Const";
export function useApi() {
const auth = useSelector(state => state.login.jwt);

View File

@ -1,3 +1,7 @@
import preval from "preval.macro";
export const ApiHost = preval`module.exports = process.env.API_HOST || '';`;
/**
* @constant {number} - Size of 1 kiB
*/

View File

@ -8,6 +8,7 @@ import {FilePaywall} from "./FilePaywall";
import {useApi} from "./Api";
import {Helmet} from "react-helmet";
import {FormatBytes} from "./Util";
import {ApiHost} from "./Const";
export function FilePreview() {
const {Api} = useApi();
@ -92,9 +93,9 @@ export function FilePreview() {
if (order) {
let orderObj = JSON.parse(order);
setOrder(orderObj);
setLink(`/d/${info.id}?orderId=${orderObj.id}`);
setLink(`${ApiHost}/d/${info.id}?orderId=${orderObj.id}`);
} else {
setLink(`/d/${info.id}`);
setLink(`${ApiHost}/d/${info.id}`);
}
}
}, [info]);

View File

@ -120,6 +120,7 @@ export function FileUpload(props) {
if (typeof (editSecret) === "string") {
req.setRequestHeader("V-EditSecret", editSecret);
}
req.withCredentials = true;
req.send(segment);
} catch (e) {
reject(e);