update de server.ts pour accepter les requetes externes

This commit is contained in:
Guams 2025-02-16 00:11:22 +01:00
parent b136e5438f
commit 789bbbf81d
2 changed files with 11 additions and 0 deletions

View File

@ -62,6 +62,10 @@
"defaultConfiguration": "production" "defaultConfiguration": "production"
}, },
"serve": { "serve": {
"options": {
"host": "0.0.0.0",
"allowedHosts": ["abonentendeur.guams.fr"]
},
"builder": "@angular-devkit/build-angular:dev-server", "builder": "@angular-devkit/build-angular:dev-server",
"configurations": { "configurations": {
"production": { "production": {

View File

@ -1,6 +1,7 @@
import { APP_BASE_HREF } from '@angular/common'; import { APP_BASE_HREF } from '@angular/common';
import { CommonEngine } from '@angular/ssr'; import { CommonEngine } from '@angular/ssr';
import express from 'express'; import express from 'express';
import cors from 'cors';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { dirname, join, resolve } from 'node:path'; import { dirname, join, resolve } from 'node:path';
import bootstrap from './src/main.server'; import bootstrap from './src/main.server';
@ -25,6 +26,12 @@ export function app(): express.Express {
index: 'index.html', index: 'index.html',
})); }));
server.use(cors({
origin: ['http://abonentendeur.guams.fr', 'http://localhost:4200'],
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
credentials: true
}));
// All regular routes use the Angular engine // All regular routes use the Angular engine
server.get('**', (req, res, next) => { server.get('**', (req, res, next) => {
const { protocol, originalUrl, baseUrl, headers } = req; const { protocol, originalUrl, baseUrl, headers } = req;