Hello,
I’ve been struggling with a redirect issue. I’m using a lambda function to serve my express app that I built. For ease of understanding I stripped my app down to a simple json response.
app.js
// Dependancies
const express = require('express');
const serverless = require('serverless-http');
const app = express();
const router = express.Router();
router.get('/', (request, response) => {
response.json({"test": "test"});
});
app.use('/.netlify/functions/app/', router);
module.exports.handler = serverless(app);
What Is Working
-
I can access my app when hitting the functions path directly ‘/.netlify/functions/app/’.
-
When I put in a 301 redirect it successfully redirected to ‘/.netlify/functions/app/’
[[redirects]]
from = “/”
to = “/.netlify/functions/app/”
What Is Not Working
[[redirects]]
from = "/"
to = "/.netlify/functions/app/"
status = 200
I even tried changing the from path to: “/hello/” instead of: “/” thinking maybe rewriting “/” wasn’t possible. But I still got the same results. I also played around (:splat) and (force = true) with no success.
Desired Situation
When I hit the index of the site I’d prefer to do a status 200 redirect and hide the ‘/.netlify/functions/app/’ portion of the url