proxy pass nextcloud request
This commit is contained in:
parent
d2db386693
commit
f339d90d00
@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
sudo docker build -t docker.kapelle.org/ncpb .
|
sudo docker build -t docker.kapelle.org/ncpb:latest .
|
||||||
|
@ -5,4 +5,4 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "8080:80"
|
||||||
environment:
|
environment:
|
||||||
- ENDPOINT=https://your.nextcloud.org/
|
- ENDPOINT=http://nextclouddockerip
|
||||||
|
@ -11,9 +11,8 @@ http {
|
|||||||
try_files ${DOLLAR}uri /index.html;
|
try_files ${DOLLAR}uri /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location = /api/endpoint {
|
location ^~ /index.php/s/ {
|
||||||
|
proxy_pass '${ENDPOINT}';
|
||||||
return 200 '${ENDPOINT}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"react-syntax-highlighter": "^15.4.3",
|
"react-syntax-highlighter": "^15.4.3",
|
||||||
"typescript": "^4.1.2"
|
"typescript": "^4.1.2"
|
||||||
},
|
},
|
||||||
|
"proxy":"https://your.nextcloud.org",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
|
18
src/App.tsx
18
src/App.tsx
@ -29,22 +29,10 @@ function App(props: Props) {
|
|||||||
const [content,setContent] = useState<string>("");
|
const [content,setContent] = useState<string>("");
|
||||||
const [title,setTitle] = useState<string>("");
|
const [title,setTitle] = useState<string>("");
|
||||||
const [lang,setLang] = useState<string>("text");
|
const [lang,setLang] = useState<string>("text");
|
||||||
const [endpoint,setEndpoint] = useState<string>("");
|
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
(async ()=>{
|
(async ()=>{
|
||||||
setEndpoint(await (await fetch("/api/endpoint")).text());
|
const response = await fetch(`/index.php/s/${props.shareID}/download`);
|
||||||
})()
|
|
||||||
},[])
|
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
(async ()=>{
|
|
||||||
if (!endpoint){
|
|
||||||
// Still loading endpoint
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(`${endpoint}/index.php/s/${props.shareID}/download`);
|
|
||||||
|
|
||||||
if (response.status === 404){
|
if (response.status === 404){
|
||||||
// File not found
|
// File not found
|
||||||
@ -67,10 +55,10 @@ function App(props: Props) {
|
|||||||
// TODO display error
|
// TODO display error
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
},[props.shareID,endpoint])
|
},[props.shareID])
|
||||||
|
|
||||||
function downloadClick() {
|
function downloadClick() {
|
||||||
window.open(`${endpoint}/index.php/s/${props.shareID}/download`, "_self");
|
window.open(`/index.php/s/${props.shareID}/download`, "_self");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user