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 ?
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.