我已經瀏覽了多篇有關此問題的帖子,但似乎無法查明問題所在。我正在為一個組織做一個捐贈頁面,需要這個來檢查貝寶是否正常工作。這是我的表單和 app.post 之間的錯誤。我得到的錯誤是: Cannot POST /path 。無法使用 /,因為它是我的聯系表單的路徑 app.get("/donate", (req, res) => res.sendFile(__dirname + "views/donate.html")); app.post("/done", (req, res) => { const create_payment_json = { intent: "sale", payer: { payment_method: "paypal", }, redirect_urls: { return_url: "https://asociacioncorazondiverso.org/donate.html", cancel_url: "https://asociacioncorazondiverso.org/donate.html", }, transactions: [ { item_list: { items: [ { name: "Donación", sku: "001", price: "10.00", currency: "USD", quantity: 1, }, ], }, amount: { currency: "USD", total: "10.00", }, description: "Donación", }, ], }; paypal.payment.create(create_payment_json, function (error, payment) { if (error) { throw error; } else { for (let i = 0; i < payment.links.length; i++) { if (payment.links[i].rel === "approval_url") { res.redirect(payment.links[i].href); } } } }); });形式:<div class="container-contact100-form-btn"> <h2>Donación de 10 USD</h2> <form action="/done" method="post"> <button type="submit" class="btn btn-warning" value="Buy">Donación</button> </form> </div>
無法發布/路徑
隔江千里
2023-07-20 14:34:28