Skip to content

Commit c4aded3

Browse files
committed
removendo limpeza e cópia de arquivos nos scripts de build, ajustando configuração do Next.js e melhorando suporte a CORS na API
1 parent 9092549 commit c4aded3

File tree

7 files changed

+24
-33
lines changed

7 files changed

+24
-33
lines changed

build_linux.sh

-10
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ echo "PORT=8001" >> .env.local
1515
npm install
1616
npm run build
1717

18-
# Limpar pasta dist anterior
19-
rm -rf dist
20-
mkdir -p dist/_next
21-
mkdir -p dist/static
22-
23-
# Copiar os arquivos do Next.js build - estrutura correta
24-
cp -r dist/_next/* dist/_next/ 2>/dev/null || true
25-
cp -r dist/static/* dist/static/ 2>/dev/null || true
26-
cp -r dist/* dist/ 2>/dev/null || true
27-
2818
cd ..
2919

3020
# Build para Linux

build_windows.sh

-9
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ echo "PORT=8001" >> .env.local
2121
npm install
2222
npm run build
2323

24-
# Limpar pasta dist anterior
25-
rm -rf dist
26-
mkdir -p dist/_next
27-
mkdir -p dist/static
28-
29-
# Copiar os arquivos do Next.js build - estrutura correta
30-
cp -r dist/_next/* dist/_next/ 2>/dev/null || true
31-
cp -r dist/static/* dist/static/ 2>/dev/null || true
32-
cp -r dist/* dist/ 2>/dev/null || true
3324

3425
cd ..
3526

frontend/next.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const nextConfig = {
77
trailingSlash: true,
88
distDir: 'dist',
99
basePath: '',
10+
assetPrefix: './'
1011
}
1112

1213
module.exports = nextConfig

linux.spec

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ block_cipher = None
66

77
# Atualizar caminhos do frontend com a estrutura correta do Next.js
88
added_files = [
9-
('frontend/dist', 'frontend/dist'), # Incluir todo o conteúdo gerado
10-
('frontend/dist/_next', 'frontend/dist/_next'), # Next.js assets e static files
11-
('frontend/dist/static', 'frontend/dist/static'), # Next.js static files
9+
('frontend/dist/', 'frontend/dist/'), # Incluir todo o conteúdo do Next.js
1210
('config.json', '.'),
1311
]
1412

m3utostrm.spec

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ icon_file = icon_path if os.path.exists(icon_path) else None
1111

1212
# Atualizar caminhos do frontend com a estrutura correta do Next.js
1313
added_files = [
14-
('frontend/dist', 'frontend/dist'), # Incluir todo o conteúdo gerado
15-
('frontend/dist/_next', 'frontend/dist/_next'), # Next.js assets e static files
16-
('frontend/dist/static', 'frontend/dist/static'), # Next.js static files
14+
('frontend\\dist', 'frontend\\dist'), # Incluir todo o conteúdo do Next.js
1715
('config.json', '.'),
1816
]
1917

2018
# Define binaries baseado no sistema operacional
2119
if sys.platform == 'win32':
2220
added_binaries = [
23-
('C:/Windows/System32/vcruntime140.dll', '.'),
24-
('C:/Windows/System32/msvcp140.dll', '.')
21+
('C:\\Windows\\System32\\vcruntime140.dll', '.'),
22+
('C:\\Windows\\System32\\msvcp140.dll', '.')
2523
]
2624
else:
2725
added_binaries = []
@@ -30,7 +28,7 @@ a = Analysis(
3028
['main.py'],
3129
pathex=[],
3230
binaries=added_binaries,
33-
datas=added_files, # Usar added_files diretamente
31+
datas=added_files,
3432
hiddenimports=[
3533
'tkinter',
3634
'requests',

main.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,19 @@ def run_api():
2121
logging.error(f"Erro ao iniciar API: {str(e)}")
2222

2323
class CORSHTTPRequestHandler(SimpleHTTPRequestHandler):
24+
def __init__(self, *args, **kwargs):
25+
directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), "frontend", "dist")
26+
super().__init__(*args, directory=directory, **kwargs)
27+
28+
def do_GET(self):
29+
# Normalizar o path para Windows
30+
self.path = self.path.replace('\\', '/')
31+
if self.path == '/' or not os.path.exists(os.path.join(self.directory, self.path.lstrip('/'))):
32+
self.path = '/index.html'
33+
return super().do_GET()
34+
2435
def end_headers(self):
36+
# Headers CORS existentes
2537
self.send_header('Access-Control-Allow-Origin', 'http://localhost:8000')
2638
self.send_header('Access-Control-Allow-Methods', '*')
2739
self.send_header('Access-Control-Allow-Headers', '*')
@@ -30,7 +42,6 @@ def end_headers(self):
3042

3143
def run_frontend():
3244
try:
33-
os.chdir("frontend/dist") # Muda para o diretório dos arquivos estáticos
3445
httpd = HTTPServer(("0.0.0.0", 8001), CORSHTTPRequestHandler)
3546
httpd.serve_forever()
3647
except Exception as e:

src/api/app.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ async def lifespan(app: FastAPI):
3838
# Configurar CORS
3939
app.add_middleware(
4040
CORSMiddleware,
41-
allow_origins=["http://localhost:8001"], # Permitir apenas o frontend
41+
allow_origins=[
42+
"http://localhost:8001",
43+
"http://127.0.0.1:8001",
44+
"http://localhost:3000",
45+
"http://127.0.0.1:3000"
46+
],
4247
allow_credentials=True,
4348
allow_methods=["*"],
4449
allow_headers=["*"],
4550
)
4651

47-
# Configurar CORS
48-
setup_cors(app)
49-
5052
# Incluir routers
5153
app.include_router(media.router, prefix="/api/media", tags=["media"])
5254
app.include_router(queue.router, prefix="/api/queue", tags=["queue"])

0 commit comments

Comments
 (0)