Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send url with hash to nodejs [closed]

How do I send URL with hash to nodejs?

When I try to send a URL with hash in it, it doesn't work, but with ? it works.

const url = require('url');
const qs = require('querystring');
const http = require('http');
    
http.createServer(server).listen(1337, 'hostname');

function server(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write(req.url);
    
    var currentURL = url.parse(req.url, true);
    console.log(currentURL);
    res.end('\nHello World\n');
}
    
console.log('Server running at http://127.0.0.1:1337/');

Use case: Facebook access_token URL format is something similar to above

like image 599
Raxit Sheth Avatar asked Apr 01 '12 19:04

Raxit Sheth


1 Answers

The part of the URL after the '#' mark, called the fragment, is not sent to the server. If you store data in the fragment, then it is up to you to process that data and do an ajax request with the data in a GET argument.

like image 99
loganfsmyth Avatar answered Sep 18 '22 10:09

loganfsmyth