Hi, everyone, I’ve setup a NextCloud and OnlyOffice integration (both as Docker container) in my localhost by following this. I’m able to create a new document (named test.docx
), open, and edit it within NextCloud. The autosave within NextCloud also worked as expected.
Now I’d like to be able to edit the same document (test.docx
) from my Express app. I keep getting this error when I’m trying to load it:
I can’t seem to find the correct document.url
and editorConfig.callbackUrl
for the initial setup. I copy the code from here.
These are things that I have tried:
- I can just go to
http://localhost:3000/test.docx
from Google Chrome and thetest.docx
will be downloaded correctly. - I have tried to make a POST request from Postman to
http://localhost:3000/track
as ineditorConfig.callbackUrl
and it returns{"error":0}
as expected.
Note:
http://localhost:3000
is my local Express server (not in Docker),http://localhost:9080
is my OnlyOffice Document server address (in Docker), and I also havehttp://localhost:8080
Nginx server (in Docker) where I can access the NextCloud to open, edit, and save the.docx
with the integrated OnlyOffice within the NextCloud
This is my index.html
that is given from accessing http://localhost:3000/
from the browser:
<!DOCTYPE html>
<html style="height: 100%;">
<head>
<title>ONLYOFFICE Api Documentation</title>
</head>
<body style="height: 100%; margin: 0;">
<div id="placeholder" style="height: 100%"></div>
<script type="text/javascript" src="http://localhost:9080/web-apps/apps/api/documents/api.js"></script>
<script type="text/javascript">
window.docEditor = new DocsAPI.DocEditor("placeholder",
{
"document": {
"fileType": "docx",
"key": "E7FAFC9C22A8",
"title": "Test.docx",
"url": "http://localhost:3000/test.docx"
},
"documentType": "text",
"editorConfig": {
"callbackUrl": "http://localhost:3000/track",
},
"height": "100%",
"width": "100%"
});
</script>
</body>
</html>
This is my server.js
file in NodeJS server:
const app = express();
app.use(express.static(path.join(__dirname, 'files')));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.disable('x-powered-by');
app.get('/', (req, res) => {
res.sendFile('index.html');
});
app.post('/track', (req, res) => {
res.send({ error: 0 }); // for testing purpose
});
Does anyone know where I can get the correct document.url
and editorConfig.callbackUrl
? Or I make a mistake in other parts? If you need additional information just ask me.