Skip to main content

Serving the Login Page

Finally, to expose the our login.html page, it's best we define an endpoint on our server. Add the following to the index.js file created in Setting Up Your Environment:

// Redirect requests from '/' to our '/login.html' file.
app.get('/login', (_, res) => {
    res.sendFile(__dirname + '/login.html');

// Start the server on port 3000.
const port = 3000;
app.listen(port, console.log(`Listening on port ${port}...`));

Note: In order for the collection process to work properly, the server should be hosted on an allowed domain specified during application onboarding.

If you're not yet ready to run the application on your public server, a temporary workaround is to add <SUBDOMAIN.YOUR_ALLOWED_DOMAIN> to your /etc/hosts file on your local development machine, and visiting <SUBDOMAIN.YOUR_ALLOWED_DOMAIN>:3000/login in your browser.

If all is well, you should see the following upon loading your login page:

Adaptive Browser SDK collection console

This login page will be hooked up to actual logic in the upcoming topics.

Next: Hosting a Well-Known Static Resource

Previous: Ensuring Collection Completes