How does express access html in a directory

  node.js, question

Static (_ _ dirname plus’ /public’) middleware was previously used. After putting my html into it and accessing it, I found that the ajax request in html was invalid.

What should I do if I want to use the form of links to directly access an html and allow network requests in this html?

I really appreciate it.

Can you provide more detailed information?

This way I use itexpress@4.13.4It is normal to implement a simple ajax get.

var path = require('path');
 var express = require('express');
 var app = express();
 
 //Define Static archival catalogue
 app.use(express.static(path.join(__dirname, 'public')));
 app.listen(3000, function () {
 console.log('app listening on port 3000');
 });
<!  DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8">
 <title>Ajax - sample</title>
 </head>
 <body>
 <input type="text" name="username" />
 <button id="btn">Get user from Github</button>
 <div>
 <div id="avatar"></div>
 <div id="username"></div>
 <div id="blog"></div>
 </div>
 <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
 <script>
 $(function () {
 $('#btn').on('click', function (e) {
 var username = $('input[name=username]').val();
 $. get ('https://api.github.com/users/'plus username, function (result) {
 console.log('ajax completed', result);
 var avatar = new Image(80, 80);
 avatar.src = result.avatar_url;
 $('#avatar').append(avatar);
 $('#username').text(result.login);
 var a = document.createElement('a');
 a.innerHTML = "BLOG"
 a.setAttribute('href', 'http://www.google.com');
 $('#blog').append(a);
 })
 });
 });
 </script>
 </body>
 </html>