javascriptnode.jslocaltunnel

How to POST request while exposing localhost using localtunnel


I'm using node js as server. Do i have to configure index.js file while using localtunnel? While submitting form, which URL do I have to specify? should i use URL provided by localtunnel.

<form name="formname" action="http://localhost:3000/register" method="post">

I know its a silly question. Can somebody provide a small guidance?


Solution

  • Assuming your routes are set up, you should just be able to post to /register like so:

    <form name="formname" action="/register" method="post">

    EDIT: Wanted to add, if you're developing in a JS environment like node, you should consider having the form action being triggered with an event listener (syntax depending on if you're using jQuery / vue.js / React / Polymer etc) that:

    1. prevents the default submit action.
    2. makes an asynchronous call to the backend using AJAX.
    3. triggers some sort of re-rendering, if you're using ES5 you'll pass a call back function, or if you're using ES6 you can use the promise chain.