Angular SSR/NodeJS suddenly CORS problems

i have two Angular SSR projects with nodeJS backend, where my cors setup was working fine. Now iam doing a third project, with the exact same setup and i get now an error message, which i can not understand:

Access to fetch at ‘https://backend.my-domain.de/login’ from origin ‘https://my-domain.de’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource

My requests do contain a ‘Access-Control-Allow-Origin’:’https://my-domain.de’, as well as my backend cors config: cors({origin: ‘https://my-domain.de’}). Since i did that successfully the two projects before, i cannot understand, why this is suddenly happening. I really hope, someone can give my a hint to that problem. Even more strange is, that this error message only gets raised by chrome, no other browser. But its not working in all browsers.

Please see my code below:
Angular Registration Service for example:

import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from 'src/environments/environment';

@Injectable({
  providedIn: 'root'
})
export class RegistrationService {

  constructor(private http: HttpClient) { }

  httpOptions = {
    headers: new HttpHeaders({
      'Content-Type':  'application/json',
      'Access-Control-Allow-Origin':'https://my-domain.de',
    })
  };

  userRegistration(body : FormData) {
    return this.http.post(environment.registration, body, this.httpOptions);
  }

}

As you can see iam parsing the httpOptions object to the request and that did work in the past.

Here is my nodeJS:

const APIconfig = require(`${__dirname}/config/config.loader.js`);
const httpRoutesConfiguration = require(`${__dirname}/config/http.routes.configuration.js`);
const CorsConfiguration = require(`${__dirname}/config/cors.config.js`)
const { logger } = require(`${__dirname}/config/logger.js`)

const express = require('express');
const server = require('http');
const WebsocketServerConfiguration = require(`${__dirname}/websocket.server.js`);
const { fromEvent } = require('rxjs');
const { tap } = require('rxjs/operators');
const mongoose = require('mongoose');

(async () => {
    try {
        const app = express();
        const API = await new APIconfig(`${__dirname}/config/APIconfig.json`).getConfig();
        mongoose.connect(API.MONGODB_PRODENVIROMENT_API);
        const serverInstance = server.createServer(app);
        fromEvent(serverInstance.listen(API.PORT, () => console.log(`Server is listening on 'http://localhost:${API.PORT}`)), 'listening')
            .pipe(
                tap(new CorsConfiguration(app)),
                tap(new httpRoutesConfiguration(app)),
                tap(new WebsocketServerConfiguration(serverInstance)),
            )
    } catch (ex) {
        logger.error(ex);
    } 
})(); 

The RxJS Tap operator applies the Cors Config on the app object.
And the cors configuration. Even if i change the origin temporary to origin: “*” doesnt help. Comment out the WebsocketServer doesnt help eather:

const cors = require('cors');

module.exports = class CorsConfiguration {

    constructor(app) {
        app.use(
            cors({
                 origin: 'https://my-app.de' // "*" did not do the job eather
            })
        )
    }
}

The http route configuration looks as follows:

const playerController = require(`${__dirname}/../controller/player.controller.js`);
const multer = require('multer');
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');

module.exports = class HttpRoutesConfiguration {

    constructor(app) {

        const storage = multer.diskStorage({
            destination: (reg, file, cb) => {
            cb(null, 'img')
            },
            filename: (reg, file, cb) => {
                cb(null, Date.now() + path.extname(file.originalname))
            }
        })

        const upload = multer({ storage: storage });

        app.use("/img", express.static('img'));     //serve static img files
       
        app.post('/registerNewPlayer', upload.single("avatarPicture"), playerController.registerNewPlayer);
    
        app.post('/login', bodyParser.json(), playerController.loginUser);

        app.post('/addPlayer', upload.single("avatarPicture"), playerController.addPlayer);

        app.post('/deleteUser', bodyParser.json(), playerController.deleteUser);
    }
}

iam running both frontend and backend on one single machine with traeffik proxy with the following configuration:

version: '3'
services:
   backend:
      image: node:latest
      command: node /usr/src/app/index.js
      volumes:
        - ./dist:/usr/src/app    
      networks:
         - default
         - web     
      labels:
         - traefik.enable=true
         - traefik.http.routers.backend.rule=Host(`backend.my-domain.de`) && PathPrefix(`/{path:.*}`)
         - traefik.http.routers.backend.tls=true
         - traefik.http.routers.backend.tls.certresolver=lets-encrypt
         - traefik.http.services.backend.loadbalancer.server.port=8080
networks:
   web:
      external: true

to clearify: Frontend runs on port 5000 with the origin “https://my-domain.de”. I also registered a subdomain https://backend.my-domain.de, which i use for the backend API calls and a corresponding rule for traeffik proxy.

Again, all of this configuration worked in the past without any single problem. I would be really thankful if you can help me. Let me know, if you need any further information. Regards, Marc

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật