使用go-gin以编程方式自动接受证书

I am using golang go-gin server for hosting an application. Both the front-end and back-end work over https and both are separate projects. The front-end makes ajax calls to the back-end which is rest API based. If I clear the browser cache (Google Chrome) and try to load the UI it does not communicate with the back-end API initially. Then in another tab I hit the base url (https://localhost:8080/) accept the certificate and then it works. Is there any way to avoid this? I want the front end should auto accept the certificate and not complain about it.

In tls.Config you can find the Certificates attribute, which could be helpful in your situation:

Certificates contains one or more certificate chains to present to the other side of the connection. Server configurations must include at least one certificate or else set GetCertificate.

Then you can use your custom tls.Config to obtain a http.Transport for your purposes

tr := &http.Transport{
    TLSClientConfig: &tls.Config{...custom config attrs...},
}