在Localhost上工作的链接无法在部署服务器上工作



我有一个网页,该页面是由Localhost运行的链接呈现的,但它在倾向于服务器上失败。

...
    //this is html page
    var view = document.createElement('a');
    $(view).addClass('btn btn-primary btn-sm')
    view.textContent = "Update";
    view.setAttribute('href', window.location.href+'/'+doc.id)
    //note : window.location.href = http://localhost:5000/<project>/app/home/
    ...`
    //this is server side
        app.get('/home/:id', (req, res) => {
            res.render('viewData', {
                params : req.params.id
            })
        })
    exports.app = functions.https.onRequest(app);

它的渲染:

app.get('*', (req,res) => res.send('Page not found'))

您可能会误导从localhost更改为部署服务器的文件的路径。

您说:window.location.href = http://localhost:5000/<project>/app/home/

将其更改为应用程序的实际实际路径,您可以通过以下方式从PHP获取它: $_SERVER['DOCUMENT_ROOT'](必要时添加此路径的子折线(

它应该起作用!

相关内容

最新更新