React opens website link after localhost url instead of https://websitelink

I get employers web addresses from a database, when I click web address text it opens as localhost:3000/webadresslink, how can I change it to https://webaddresslink

import React, { useState, useEffect } from 'react'
import EmployerService from '../../services/employerService'
import { Styles } from './style'
import { Card, Container } from 'react-bootstrap'

const EmployersList = () => {
  const [employers, setEmployers] = useState([])

  useEffect(() => {
    let employerService = new EmployerService()
    employerService.getAllEmployers().then(result => setEmployers(
  return (
 => (
                  <a href={employer.webAddress} target="blank">


Because isn’t an absolute URL. It may intuitively look like one to you, but it isn’t structurally any different from other relative URLs like:

  • index.html
  • www.index.html
  • etc.

To tell the browser that this is a URL for a different host you’ll need to prefix it:


Or even simply:

  • //

If the data being displayed isn’t well organized and some URL values have a prefix and some don’t then a workable attempt at front-end logic could be simply: If the value doesn’t contain “//” then prefix it with “//”. For example:

  employer.webAddress.includes('//') ?
  employer.webAddress :