NGRX在转到HTTPS之前将怪异的重定向重定向到HTTP

发布于 2025-01-25 06:44:14 字数 1949 浏览 1 评论 0 原文

我是NGRX的新手,我想使用NGRX数据模块。我与Traefik(HTTPS模式)在Docker中托管的Angular/Symfony堆叠在一起。

我想向名为: https://xxx.xxxxxxxxx x.localhost/operations ) 这条路线通常会给我发送带有Angular Service标准用法的操作列表。

但是使用NGRX数据模块时,我称此路线时会有一个CORS错误。

ngrx配置:

exp.module.ts中的我的自定义端点adress:

imports: [
  HttpClientModule,
  StoreModule.forRoot({}),
  StoreRouterConnectingModule.forRoot(),
  StoreDevtoolsModule.instrument({
   name: 'NgRx demo setup App',
  }),
  EffectsModule.forRoot([]),
  EntityDataModule.forRoot(entityConfig)
],
providers:[
  {
    provide: DefaultDataServiceConfig,
    useValue: {
       root: "https://xxx.xxxx.localhost/",
    }
  }
]

extityconfig.ts:

import {EntityMetadataMap} from '@ngrx/data';

const entityMetadata: EntityMetadataMap = {
  Operation: {},
};

export const entityConfig = {
  entityMetadata
};

我的操作 - service.ts with ngrx:

import { Injectable } from '@angular/core';
import {EntityCollectionServiceBase, EntityCollectionServiceElementsFactory} from "@ngrx/data";

import {Operation} from "@models/entities/operation.model";

@Injectable({ providedIn: 'root' })
export class NgxOperationService extends EntityCollectionServiceBase<Operation> {
  constructor(serviceElementsFactory: EntityCollectionServiceElementsFactory) {
    super('Operation', serviceElementsFactory);
  }
}

在组件中致电:

ngOnInit() {
  this._operationServiceX.getAll()
}

在chrome的网络面板中,我看到一个可疑调用,我看到一个可疑的呼叫CORS错误: 在调用之前a href =“ https://api.xxxx.localhost/operations” rel =“ nofollow noreferrer”> https://api.xxxx.localhost/operations/aperations ,我没有第一次ngrx数据。致电导致我的CORS错误的HTTP。

在chrome中捕获网络面板

任何人都可以帮助我吗?

I'm new with ngrx and I want to use NgRx Data module. I'm in a stack with Angular/Symfony hosted in docker with Traefik (https mode).

I want to do a request to a route named : https://xxx.xxxxxx.localhost/operations
This route normally send me my list of operations with standard usage with angular service.

But with NgRx Data module when I called this route I have an CORS ERROR.

NgRx Configuration :

Import and config to my custom endpoint adress in app.module.ts :

imports: [
  HttpClientModule,
  StoreModule.forRoot({}),
  StoreRouterConnectingModule.forRoot(),
  StoreDevtoolsModule.instrument({
   name: 'NgRx demo setup App',
  }),
  EffectsModule.forRoot([]),
  EntityDataModule.forRoot(entityConfig)
],
providers:[
  {
    provide: DefaultDataServiceConfig,
    useValue: {
       root: "https://xxx.xxxx.localhost/",
    }
  }
]

entityConfig.ts :

import {EntityMetadataMap} from '@ngrx/data';

const entityMetadata: EntityMetadataMap = {
  Operation: {},
};

export const entityConfig = {
  entityMetadata
};

My operation-service.ts with NgRx :

import { Injectable } from '@angular/core';
import {EntityCollectionServiceBase, EntityCollectionServiceElementsFactory} from "@ngrx/data";

import {Operation} from "@models/entities/operation.model";

@Injectable({ providedIn: 'root' })
export class NgxOperationService extends EntityCollectionServiceBase<Operation> {
  constructor(serviceElementsFactory: EntityCollectionServiceElementsFactory) {
    super('Operation', serviceElementsFactory);
  }
}

Call in the component :

ngOnInit() {
  this._operationServiceX.getAll()
}

In my network panel in Chrome I see a suspicious call that doing my CORS ERROR :
Before it's call http://api.xxxx.localhost/operations/ that doing a redirect to https://api.xxxx.localhost/operations and I don't no why NgRx Data doing this first call to an HTTP that cause my CORS ERROR.

Capture of network panel in chrome

Anyone can help me ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

强者自强 2025-02-01 06:44:14

这可能不是由NGRX数据引起的。
请确保您可以执行相同的请求,而无需使用NGRX数据。

服务器可能需要接受Angular客户端的请求。

This probably isn't caused by ngrx data.
Please make sure that you can execute the same request, without using ngrx data.

The server probably needs to accept requests from the angular client.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文