# BE API Domain TLS Fix (`apibazzar.softcomp.io`)

## Ringkasan

Error login di FE **bukan dari kode FE**. Sumber masalah ada di sisi BE/infra domain API.

Gejala dari browser/FE:

- `net::ERR_SSL_UNRECOGNIZED_NAME_ALERT`

Hasil pengecekan server:

- `http://apibazzar.softcomp.io` -> redirect ke HTTPS (301) ✅
- `https://apibazzar.softcomp.io` -> TLS gagal ❌
- Nginx vhost aktif untuk bazzar ternyata:
  - `ssl_reject_handshake on;`
  - `return 444;`

Ini membuat semua request HTTPS ke API gagal sebelum masuk ke aplikasi Go.

## Lokasi Konfigurasi Bermasalah

File:

- `/etc/nginx/sites-enabled/default.conf`

Block yang bermasalah (contoh):

```nginx
server {
    listen 443 ssl;
    listen [::]:443 ssl;

    ssl_reject_handshake on;
    server_name apibazzar.softcomp.io;
    return 444;

    ssl_certificate /etc/letsencrypt/live/apibazzar.softcomp.io/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/apibazzar.softcomp.io/privkey.pem;
}
```

## Konfigurasi yang Seharusnya

Ubah server block `443` untuk `apibazzar.softcomp.io` menjadi reverse proxy ke backend Go (`127.0.0.1:8090`):

```nginx
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name apibazzar.softcomp.io;

    ssl_certificate /etc/letsencrypt/live/apibazzar.softcomp.io/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/apibazzar.softcomp.io/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8090;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name apibazzar.softcomp.io;
    return 301 https://$host$request_uri;
}
```

## Setelah Diubah

Jalankan:

```bash
nginx -t
systemctl reload nginx
```

Verifikasi:

```bash
curl -I https://apibazzar.softcomp.io/api/v1/healthz
```

Harus dapat response HTTP (misal `200`), bukan TLS error.

## Catatan Tambahan

Setelah TLS beres, login masih perlu implementasi endpoint auth karena saat ini:

- `POST /api/v1/auth/login` masih `501 not implemented`

Lihat dokumen lanjutan:

- `docs/AUTH_LOGIN_IMPLEMENTATION.md`

