Skip to content

Commit 294f908

Browse files
committed
Add SSL certificate troubleshooting guide and enhance deployment configuration
- Create CERTIFICATE_FIX.md to address ERR_CERT_COMMON_NAME_INVALID issues with detailed solutions and verification steps. - Update GitHub Actions workflow to ensure CNAME and .nojekyll files are copied to the dist directory for proper deployment. - Add security headers in public/_headers for improved security practices. - Introduce cert-check.html for SSL verification and redirection handling. - Add security.txt for contact information and preferred languages.
1 parent 074c187 commit 294f908

File tree

6 files changed

+142
-1
lines changed

6 files changed

+142
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ jobs:
4646
- name: Copy 404.html for SPA routing
4747
run: cp dist/index.html dist/404.html
4848

49+
- name: Ensure CNAME is in dist
50+
run: |
51+
if [ -f public/CNAME ]; then
52+
cp public/CNAME dist/CNAME
53+
echo "CNAME copied to dist"
54+
fi
55+
if [ -f .nojekyll ]; then
56+
cp .nojekyll dist/.nojekyll || true
57+
echo ".nojekyll copied to dist"
58+
fi
59+
4960
- name: Setup Pages
5061
uses: actions/configure-pages@v4
5162

CERTIFICATE_FIX.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Fix para ERR_CERT_COMMON_NAME_INVALID
2+
3+
## O Problema
4+
5+
O erro `ERR_CERT_COMMON_NAME_INVALID` ocorre quando:
6+
- O certificado SSL não corresponde ao domínio acessado
7+
- Há um problema com www vs non-www
8+
- O CNAME não está configurado corretamente no GitHub
9+
10+
## Soluções Aplicadas
11+
12+
### 1. CNAME Configurado
13+
- ✅ Arquivo `CNAME` com `duckdevlabs.com` (sem www)
14+
- ✅ CNAME copiado automaticamente no build
15+
16+
### 2. Workflow Atualizado
17+
- ✅ Garantindo que CNAME e .nojekyll sejam copiados para dist/
18+
19+
## Verificações Necessárias no GitHub
20+
21+
### 1. Verificar Configuração do Domínio
22+
1. Vá em **Settings → Pages**
23+
2. Em **Custom domain**, deve estar: `duckdevlabs.com` (sem www)
24+
3. O **SSL** deve estar **enabled**
25+
26+
### 2. Verificar DNS
27+
Execute no terminal:
28+
```bash
29+
dig duckdevlabs.com +short
30+
# Deve retornar algo como: 185.199.108.153
31+
```
32+
33+
### 3. Verificar Certificado SSL
34+
1. Acesse `https://duckdevlabs.com`
35+
2. Clique no **cadeado** na barra de endereços
36+
3. Veja os detalhes do certificado
37+
4. Deve mostrar: **Issued to: duckdevlabs.com**
38+
39+
## Se o Problema Persistir
40+
41+
### Opção 1: Limpar Cache do GitHub Pages
42+
1. Em Settings → Pages, remova o domínio customizado
43+
2. Salve
44+
3. Aguarde 5 minutos
45+
4. Adicione novamente: `duckdevlabs.com`
46+
5. Aguarde a propagação do DNS (pode levar até 24h)
47+
48+
### Opção 2: Verificar DNS
49+
Certifique-se que o DNS aponta para:
50+
```
51+
Type: CNAME
52+
Name: duckdevlabs.com
53+
Value: duckdevlabs.github.io
54+
```
55+
56+
OU se usar A records:
57+
```
58+
185.199.108.153
59+
185.199.109.153
60+
185.199.110.153
61+
185.199.111.153
62+
```
63+
64+
### Opção 3: Forçar HTTPS no Navegador
65+
Adicione no console do navegador:
66+
```javascript
67+
// Redireciona www para non-www
68+
if (location.hostname === 'www.duckdevlabs.com') {
69+
location.replace('https://duckdevlabs.com' + location.pathname);
70+
}
71+
```
72+
73+
## Testar Localmente
74+
75+
```bash
76+
# Build
77+
npm run build
78+
79+
# Preview
80+
npm run preview
81+
82+
# Acesse http://localhost:4173
83+
# Não deve ter erro de certificado localmente
84+
```
85+
86+
## Logs Úteis
87+
88+
No console do navegador, execute:
89+
```javascript
90+
// Ver URLs dos recursos carregados
91+
Array.from(document.querySelectorAll('link[rel="stylesheet"]')).forEach(link => {
92+
console.log('CSS:', link.href);
93+
});
94+
95+
// Verificar protocolo
96+
console.log('Protocol:', location.protocol);
97+
console.log('Hostname:', location.hostname);
98+
```
99+

public/.well-known/security.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Contact: mailto:hello@duckdevlabs.dev
2+
Expires: 2025-12-31T23:59:59.000Z
3+
Preferred-Languages: pt-BR, en
4+

public/_headers

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
Strict-Transport-Security: max-age=31536000; includeSubDomains
3+
X-Content-Type-Options: nosniff
4+
X-Frame-Options: DENY
5+
X-XSS-Protection: 1; mode=block
6+
Referrer-Policy: strict-origin-when-cross-origin
7+

public/cert-check.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>SSL Check</title>
6+
</head>
7+
<body>
8+
<h1>SSL Certificate Check</h1>
9+
<p>If you see this, SSL is working but there might be a redirect issue.</p>
10+
<script>
11+
console.log('Current URL:', window.location.href);
12+
console.log('Protocol:', window.location.protocol);
13+
console.log('Hostname:', window.location.hostname);
14+
if (window.location.hostname.includes('www.')) {
15+
window.location.href = window.location.href.replace('www.', '');
16+
}
17+
</script>
18+
</body>
19+
</html>
20+

vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default defineConfig({
1717
},
1818
},
1919
],
20-
base: '/',
20+
base: process.env.NODE_ENV === 'production' ? '/' : '/',
2121
build: {
2222
assetsDir: 'assets',
2323
outDir: 'dist',

0 commit comments

Comments
 (0)