proxy pass nextcloud request
This commit is contained in:
parent
d2db386693
commit
f339d90d00
@ -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 .
|
||||
|
@ -5,4 +5,4 @@ services:
|
||||
ports:
|
||||
- "8080:80"
|
||||
environment:
|
||||
- ENDPOINT=https://your.nextcloud.org/
|
||||
- ENDPOINT=http://nextclouddockerip
|
||||
|
@ -11,9 +11,8 @@ http {
|
||||
try_files ${DOLLAR}uri /index.html;
|
||||
}
|
||||
|
||||
location = /api/endpoint {
|
||||
|
||||
return 200 '${ENDPOINT}';
|
||||
location ^~ /index.php/s/ {
|
||||
proxy_pass '${ENDPOINT}';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
18
src/App.tsx
18
src/App.tsx
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user