proxy pass nextcloud request

This commit is contained in:
Niklas 2021-02-12 16:27:34 +01:00
parent d2db386693
commit f339d90d00
5 changed files with 8 additions and 20 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/env sh
sudo docker build -t docker.kapelle.org/ncpb .
sudo docker build -t docker.kapelle.org/ncpb:latest .

View File

@ -5,4 +5,4 @@ services:
ports:
- "8080:80"
environment:
- ENDPOINT=https://your.nextcloud.org/
- ENDPOINT=http://nextclouddockerip

View File

@ -11,9 +11,8 @@ http {
try_files ${DOLLAR}uri /index.html;
}
location = /api/endpoint {
return 200 '${ENDPOINT}';
location ^~ /index.php/s/ {
proxy_pass '${ENDPOINT}';
}
}

View File

@ -15,6 +15,7 @@
"react-syntax-highlighter": "^15.4.3",
"typescript": "^4.1.2"
},
"proxy":"https://your.nextcloud.org",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",

View File

@ -29,22 +29,10 @@ function App(props: Props) {
const [content,setContent] = useState<string>("");
const [title,setTitle] = useState<string>("");
const [lang,setLang] = useState<string>("text");
const [endpoint,setEndpoint] = useState<string>("");
useEffect(()=>{
(async () =>{
setEndpoint(await (await fetch("/api/endpoint")).text());
})()
},[])
useEffect(()=>{
(async ()=>{
if (!endpoint){
// Still loading endpoint
return
}
const response = await fetch(`${endpoint}/index.php/s/${props.shareID}/download`);
const response = await fetch(`/index.php/s/${props.shareID}/download`);
if (response.status === 404){
// File not found
@ -67,10 +55,10 @@ function App(props: Props) {
// TODO display error
}
})()
},[props.shareID,endpoint])
},[props.shareID])
function downloadClick() {
window.open(`${endpoint}/index.php/s/${props.shareID}/download`, "_self");
window.open(`/index.php/s/${props.shareID}/download`, "_self");
}
return (