I want to reply to Fetch request with a URL in string format. Examples I've seen look fairly easy, but I believe my cors middleware may be messing something up.
Here is my server:
const express = require('express');
const cors = require('cors');
const db = require('./database/db');
const app = express();
app.use(cors());
app.use(require('./router.img.js'));
app.listen(4000, console.log('Listening on 4000'));
module.exports = app;
Here's where I send the response:
exports.postImage = (req, res) => {
let sliceIndex = req.file.originalname.indexOf('.');
let fileType = req.file.originalname.slice(sliceIndex);
let url = "https://instaimages.sfo2.digitaloceanspaces.com/" +
req.body.number + fileType;
res.set('Content-Type', 'text/html');
res.send(url);
};
I see a response on the front-end, but it does not contain the URL string. Here is what it looks like:
Response {type: "cors", url: "http://localhost:4000/upload/",
redirected: false, status: 200, ok: true, …}