forked from Kieran/void.cat
Add API_HOST to upload/download
This commit is contained in:
parent
d82c43bb3e
commit
bd2464bd47
@ -1,7 +1,5 @@
|
|||||||
import {useSelector} from "react-redux";
|
import {useSelector} from "react-redux";
|
||||||
import preval from "preval.macro";
|
import {ApiHost} from "./Const";
|
||||||
|
|
||||||
const ApiHost = preval`module.exports = process.env.API_HOST || '';`;
|
|
||||||
|
|
||||||
export function useApi() {
|
export function useApi() {
|
||||||
const auth = useSelector(state => state.login.jwt);
|
const auth = useSelector(state => state.login.jwt);
|
||||||
|
@ -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
|
* @constant {number} - Size of 1 kiB
|
||||||
*/
|
*/
|
||||||
|
@ -8,6 +8,7 @@ import {FilePaywall} from "./FilePaywall";
|
|||||||
import {useApi} from "./Api";
|
import {useApi} from "./Api";
|
||||||
import {Helmet} from "react-helmet";
|
import {Helmet} from "react-helmet";
|
||||||
import {FormatBytes} from "./Util";
|
import {FormatBytes} from "./Util";
|
||||||
|
import {ApiHost} from "./Const";
|
||||||
|
|
||||||
export function FilePreview() {
|
export function FilePreview() {
|
||||||
const {Api} = useApi();
|
const {Api} = useApi();
|
||||||
@ -92,9 +93,9 @@ export function FilePreview() {
|
|||||||
if (order) {
|
if (order) {
|
||||||
let orderObj = JSON.parse(order);
|
let orderObj = JSON.parse(order);
|
||||||
setOrder(orderObj);
|
setOrder(orderObj);
|
||||||
setLink(`/d/${info.id}?orderId=${orderObj.id}`);
|
setLink(`${ApiHost}/d/${info.id}?orderId=${orderObj.id}`);
|
||||||
} else {
|
} else {
|
||||||
setLink(`/d/${info.id}`);
|
setLink(`${ApiHost}/d/${info.id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [info]);
|
}, [info]);
|
||||||
|
@ -120,6 +120,7 @@ export function FileUpload(props) {
|
|||||||
if (typeof (editSecret) === "string") {
|
if (typeof (editSecret) === "string") {
|
||||||
req.setRequestHeader("V-EditSecret", editSecret);
|
req.setRequestHeader("V-EditSecret", editSecret);
|
||||||
}
|
}
|
||||||
|
req.withCredentials = true;
|
||||||
req.send(segment);
|
req.send(segment);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(e);
|
reject(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user