I am building a Node app that uses Express, Vue and ThreeJS. I have this setup for express in the backend:
const app = express();
app.post('*', (req, res) => {
const options = {
headers: {
'url': req.body.url
}
}
res.sendFile(path.join(__dirname, 'public/index.html'), options);
});
The file “index.html” contains:
<script type="module" src="/src/main.js"></script>
And “main.js” is where the Vue main view is mounted.
Now, the URL that is contained in “options” refers to a 3D mesh file that will be loaded by ThreeJS in the Vue view (frontend). So what I need to know is how to get that “options” inside the Vue view to get the URL from it. Is there a way to read the headers from a Vue view?
And if there is another approach to get to do this, I would like to know it. I am quite lost regarding Node in general.
I was thinking on using a template instead of “index.html” and create an html element with value={ url }, so I could read the DOM with the Vue app somehow, but it sounds quite goofy. I haven’t tried it though, there has to be a better way.