I am building a simple web app using node js express and cloud firebase functions
i have 2 endpoints, 1. first point renders the form(GET request) and 2. POST endpoint that takes the form data on submit
for some reason firebase skipping the function name in the post url(2nd end point) on form submission but it works fine on local express server
example: if form acion attribute value is "check" and firebase function name is "helloWorld"
the form submit url should be "<default firebase pefix>/helloWorld/check"
but instead the url it posting to is "<default firebase pefix>/check"
.
firebase function name in the url is getting skipped. which is giving me function not found in location us-central etc
another thing i observed is if i give slash as prefix to action attribute value like "action = "\check". firebase skipping the whole base url and appending from attribute value the port value
i tried a work around by setting the static absolute path (path after production) to the form action attribute.
But i want to if its a bug or am i missing something
<form action="check" method="POST"
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<button type="submit">Login</button>
</form>
// action = "/check" this is skipping total base url all together
const functions = require('firebase-functions');
const express = require('express')
const bodyparser = require('body-parser')
const app = express()
app.set('port',6000)
app.use(bodyparser.json())
app.use(bodyparser.urlencoded({extended:true}))
app.set('view engine', 'ejs');
app.get('/',(req,res)=>{
res.render('formfill')
})
// this below end point is supposed to get triggered on form submission.
// and it is working fine on local express server, but not on firebase functions
app.post('/check',(req,res)=>{
res.send(`you said ${req.body.uname}`)
})
exports.helloWorld = functions.https.onRequest(app);