при клике на имя/аватар пользователя, не переходит по его ссылке:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" href="/css/main.css" />
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" href="/jquery-ui/themes/base/all.css" />
    <title>Home</title>
  </head>
  <body>
    <header>
      <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <a class="navbar-brand" href="/">My Musician Site</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav ml-auto">
            <li class="nav-item active">
              <a class="nav-link" href="/">Home</a>
            </li>
            <% if (userLoggedIn) { %>
            <li class="nav-item">
              <a class="nav-link" href="/profile/<%= musician.id %>">Hello, <%= username %></a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/logout">Logout</a>
            </li>
            <% } else { %>
            <li class="nav-item">
              <a class="nav-link" href="/register">Register</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/login">Login</a>
            </li>
            <% } %>
          </ul>
        </div>
      </nav>
    </header>
    <main class="container mt-5">
      <div class="row">
        <div class="col-md-8">
        <!-- добавляет форму с поиском музыкантом -->
        <form method="get" action="/search">
          <div class="form-group">
            <label for="query">Search by name or genre:</label>
            <div class="input-group">
              <input id="query" name="query" type="text" class="form-control" value="<%= query %>">
              <div class="input-group-append">
                <button type="submit" class="btn btn-primary">Search</button>
              </div>
            </div>
          </div>
          <div class="form-row">
            <div class="form-group col-md-4">
              <label for="role">Search by role:</label>
              <select id="role" name="role" class="form-control">
                <option value="">
                  All
                </option>
                <option value="Band">
                  Band
                </option>
                <option value="Artist">
                  Artist
                </option>
              </select>
            </div>
            <div class="form-group col-md-4">
              <label for="genre">Search by genre:</label>
              <select id="genre" name="genre" class="form-control">
                <option value="">
                  All
                </option>
                <option value="Rock">
                  Rock
                </option>
                <option value="Pop">
                  Pop
                </option>
              </select>
            </div>
            <div class="form-group col-md-4">
              <label for="city">Search by location:</label>
              <input id="city" name="city" type="text" class="form-control" autocomplete="on" value="<%= city %>" data-value="">
            </div>
          </div>
        </form>
        <%if (musicians.length > 0) { %>
        <h2 class="mt-5">Results:</h2>
        <ul class="list-unstyled">
        <% musicians.forEach(musician => { %>
          <li class="media my-4">
            <a href="<%= musician.profileLink %>">
              <img src="/img/<%= musician.thumbnail || 'avatar.jpg'%>" class="mr-3" alt="Musician profile picture">
            </a>
            <div class="media-body">
              <h5 class="mt-0 mb-1"><%= musician.name %></h5>
              <p><strong>Role:</strong> <%= musician.role %></p>
              <p><strong>Genre:</strong> <%= musician.genre %></p>
              <p><strong>Location:</strong> <%= musician.city %></p>
              <p><strong>Available for gigs:</strong> <%= musician.availableForGigs ? 'Yes' : 'No' %></p>
            </div>
          </li>
        <% }) %>
        </ul>
        <% } else { %>
        <h2 class="mt-5">No results found</h2>
        <% } %>
        </div>
        <div class="col-md-4">
          <h2>About this site</h2>
          <p>Welcome to My Musician Site! This is a platform for musicians to connect with each other and find potential bandmates or collaborators. You can search for musicians by name, location, role, and genre. If you're a musician yourself, make sure to create a profile so others can find you too!</p>
          <p>If you have any questions or feedback, please don't hesitate to contact us at <a href="mailto:contact@mymusiciansite.com">contact@mymusiciansite.com</a>.</p>
        </div>
      </div>
    </main>
    <script src="/jquery/jquery.min.js"></script>
    <script src="/jquery-ui/jquery-ui.min.js"></script>
    <script src="/js/main.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1r RibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>

app.js:

const express = require("express");
const fs = require("fs");
const session = require("express-session");
const fileUpload = require("express-fileupload");
const app = express();
const fuzzball = require("fuzzball");
const mysql = require('mysql');

const connection = mysql.createConnection({
  host: 'localhost',
  user: 'music', // замените на свой логин
  password: 'password', // замените на свой пароль
  database: 'music' // замените на свою базу данных
});

connection.connect((err) => {
  if (err) {
    console.error('Ошибка подключения к базе данных: ', err);
  } else {
    console.log('Подключение к базе данных успешно');
  }
});

app.set("view engine", "ejs");
app.use(express.static("public"));

app.use(express.urlencoded({ extended: true }));
app.use(fileUpload());
app.use(session({
  secret: "mysecretkey",
  resave: false,
  saveUninitialized: false
}));






const citiesAndRegions = JSON.parse(fs.readFileSync("./db/russia.json", "utf8"));


//const predefinedGenres = ['Rock', 'Pop', 'Jazz', 'Hip Hop', 'Electronic', 'Blues'];

function getLastNRegisteredMusicians(N) {
  const data = fs.readFileSync("./db/musicians.json");
  const musicians = JSON.parse(data);

  return musicians.musicians.slice(-3);
}

function getMusicianById(id) {
  const data = fs.readFileSync("./db/musicians.json");
  const musicians = JSON.parse(data);

  return musicians.musicians.find(musician => musician.id === id);
}

function requireLogin(req, res, next) {
  if (req.session.musicianId) {
    next();
  } else {
    res.redirect("/login");
  }
}

function search(query = '', role = '', city = '', genre = '') {
  const data = fs.readFileSync('./db/musicians.json');
  
  const musicians = JSON.parse(data).musicians.map(musician => {
    return {
      name: musician.name,
      genre: musician.genre,
      originalName: musician.name,
      profileLink: `/profile/${musician.id}`,
      thumbnail: musician.thumbnail,
      soundcloud: musician.soundcloud,
      role: musician.role,
	  city: musician.city
      
    };
  });

  let results = [];

  if (query || role || city || genre) {
    const lowerQuery = query.toLowerCase();
    results = musicians.filter(musician => {
      const nameScore = musician.name.toLowerCase().startsWith(lowerQuery) ? 2 : musician.name.toLowerCase().includes(lowerQuery) ? 1 : 0;
      const genreScore = musician.genre.toLowerCase().startsWith(lowerQuery) ? 2 : musician.genre.toLowerCase().includes(lowerQuery) ? 1 : 0;
      
     return (
    nameScore + genreScore > 0 &&
    (role === "" || musician.role === role) &&
	(city === "" || (musician.city && musician.city.toLowerCase().trim() === city.toLowerCase().trim())) &&
    (genre === "" || musician.genre.toLowerCase() === genre.toLowerCase())
  );

    }).sort((a, b) => {
      const aNameScore = a.name.toLowerCase().startsWith(lowerQuery) ? 2 : a.name.toLowerCase().includes(lowerQuery) ? 1 : 0;
      const bNameScore = b.name.toLowerCase().startsWith(lowerQuery) ? 2 : b.name.toLowerCase().includes(lowerQuery) ? 1 : 0;
      const aGenreScore = a.genre.toLowerCase().startsWith(lowerQuery) ? 2 : a.genre.toLowerCase().includes(lowerQuery) ? 1 : 0;
      const bGenreScore = b.genre.toLowerCase().startsWith(lowerQuery) ? 2 : b.genre.toLowerCase().includes(lowerQuery) ? 1 : 0;

      // Sort by name score, then genre score, then location score (descending)
      if (aNameScore + aGenreScore + a.location < bNameScore + bGenreScore + b.location) {
        return 1;
      } else if (aNameScore + aGenreScore + a.location > bNameScore + bGenreScore + b.location) {
        return -1;
      } else {
        return 0;
      }
    });

    // Remove duplicates
    results = results.filter((result, index, self) =>
      index === self.findIndex(r => (
        r.name === result.name && r.genre === result.genre && r.city === result.city
      ))
    );
  }

  return results;
}

app.use((req, res, next) => {
  if (req.session.musicianId) {
    const musician = getMusicianById(req.session.musicianId);
    res.locals.musician = musician;
    res.locals.userLoggedIn = true;
    res.locals.username = musician.name;
  } else {
    res.locals.userLoggedIn = false;
  }

  next();
});

app.get("/", (req, res) => {
  const data = fs.readFileSync("./db/musicians.json");
  const musicians = JSON.parse(data);
  const lastRegisteredMusicians = getLastNRegisteredMusicians(5);
  
  res.render("index", { musicians: lastRegisteredMusicians, query:'',city:'',role:''});
  
});

app.get("/autocomplete/cities", async (req, res) => {
  const searchString = req.query.term;
  
  connection.query(
    "SELECT city FROM mytable WHERE city LIKE ?",
    [searchString + '%'],
    (error, results, fields) => {
      if (error) {
        console.error("Ошибка выполнения запроса: ", error);
        res.status(500).send("Ошибка выполнения запроса");
      } else {
        const cities = results.map(row => row.city);
        res.json(cities);
      }
    }
  );
});

app.get("/register", (req, res) => {
  if (req.session.musicianId) {
    const musician = getMusicianById(req.session.musicianId);
    res.redirect("/profile/" + musician.id);
  } else {
	  
	  
	  
    res.render("register", { citiesAndRegions, city:'' });
  }
});

app.post("/register", (req, res) => {
  if (req.session.musicianId) {
    const musician = getMusicianById(req.session.musicianId);
    res.redirect("/profile/" + musician.id);
  } else {
    const data = fs.readFileSync("./db/musicians.json");
    const musicians = JSON.parse(data);

    const newMusician = {
      id: musicians.musicians.length + 1,
      name: req.body.name,
      genre: req.body.genre,
      instrument: req.body.instrument,
      soundcloud: req.body.soundcloud,
      password: req.body.password,
	  role: req.body.role,
	  city: req.body.city,
      login: req.body.login
    };
	
	


    if (req.files && req.files.thumbnail) {
      const file = req.files.thumbnail;
      const filename = "musician_" + newMusician.id + "_" + file.name;
      file.mv("./public/img/" + filename);

      newMusician.thumbnail = filename;
    }
	
	const found = citiesAndRegions.find(
  ({ city }) => city === req.body.city.toLowerCase()
);

// Если найдено - сохраняем город и регион, если нет - оставляем только город
if (found) {
  newMusician.city = found.city;
  newMusician.region = found.region;
} else {
  newMusician.city = req.body.city;
  newMusician.region = "";
}

    musicians.musicians.push(newMusician);
    fs.writeFileSync("./db/musicians.json", JSON.stringify(musicians));

    req.session.musicianId = newMusician.id;
    res.redirect("/profile/" + newMusician.id);
  }
});

app.get("/profile/:id", (req, res) => {
  const musician = getMusicianById(parseInt(req.params.id));

  if (musician) {
    res.render("profile", { musician: musician, city:'', query:'', role:'' });
  } else {
    res.status(404).send("Musician not found");
  }
});

app.get("/login", (req, res) => {
  res.render("login");
});

app.post("/login", (req, res) => {
  const data = fs.readFileSync("./db/musicians.json");
  const musicians = JSON.parse(data);

  const musician = musicians.musicians.find(musician => musician.login === req.body.login && musician.password === req.body.password);

  if (musician) {
    req.session.musicianId = musician.id;
    res.redirect("/profile/" + musician.id);

  } else {
    res.render("login", { error: "Invalid login or password" });
  }
});

app.get("/logout", (req, res) => {
  req.session.destroy();
  res.redirect("/");
});

app.get('/search', (req, res) => {
  const query = req.query.query || '';
  const role = req.query.role || '';
  const city = req.query.city || '';
  const genre = req.query.genre || '';
  
  let musicians = [];

  if (query || role || city || genre) {
    musicians = search(query, role, city, genre);
  } else {
    const data = fs.readFileSync('./db/musicians.json');
    musicians = JSON.parse(data).musicians.map(musician => {
      return {
        name: musician.name,
        genre: musician.genre,
        originalName: musician.name,
        profileLink: `/profile/${musician.id}`,
        thumbnail: musician.thumbnail,
        soundcloud: musician.soundcloud,
        role: musician.role,
		city: musician.city
      };
    });
  }

  //res.locals.predefinedGenres = predefinedGenres;
  app.locals.JSON = JSON;
  res.render('search', { musicians, query, role, city, genre, citiesAndRegions});

  //res.redirect('/search');
});

app.get("/profile/:id/edit", requireLogin, (req, res) => {
  const musician = getMusicianById(parseInt(req.params.id));

  if (musician) {
    if (req.session.musicianId === musician.id) { // Check if the logged-in user is the owner of the profile
      res.render("edit-profile", { musician: musician });
    } else {
      res.status(403).send("Access denied");
    }
  } else {
    res.status(404).send("Musician not found");
  }
});





app.post('/profile/:id/edit', requireLogin, (req, res) => {
  const musician = getMusicianById(parseInt(req.params.id));

  if (musician) {
    if (!req.body.name || !req.body.genre) {
      res.status(400).send('Please fill out all fields');
    
    } else {
      musician.name = req.body.name;
      musician.genre = req.body.genre;
      musician.instrument = req.body.instrument;
      musician.soundcloud = req.body.soundcloud;
	  musician.soundcloud1 = req.body.soundcloud1;
  musician.soundcloud2 = req.body.soundcloud2;
      musician.city = req.body.city;
	  musician.role = req.body.role;
      musician.bio = req.body.bio;

      if (req.files && req.files.thumbnail) {
        const file = req.files.thumbnail;
        const filename = 'musician_' + musician.id + '_' + file.name;
        file.mv('./public/img/' + filename);
        musician.thumbnail = filename;
      }

      const data = fs.readFileSync('./db/musicians.json');
      const musicians = JSON.parse(data);
      const index = musicians.musicians.findIndex(m => m.id === musician.id);
      musicians.musicians[index] = musician;

      fs.writeFileSync('./db/musicians.json', JSON.stringify(musicians));

      res.redirect('/profile/' + musician.id);
    }
  } else {
    res.status(404).send('Musician not found');
  }
  
  
});

function isValidSoundCloudUrl(url) {
  return url.startsWith('https://soundcloud.com/');
}

app.listen(3000, () => {
  console.log("Server started on port 3000");
});