fixed the program.cs and run in VC code

This commit is contained in:
2026-07-30 17:23:48 +10:00
parent ce2b3ba8c9
commit 5d2e989ee9
112 changed files with 17313 additions and 17245 deletions
+38
View File
@@ -0,0 +1,38 @@
import { HttpInterceptorFn } from '@angular/common/http';
export const credentialsInterceptor: HttpInterceptorFn = (req, next) => {
// Clone the request to add the withCredentials property
const clonedRequest = req.clone({
withCredentials: true
});
return next(clonedRequest);
};
typescriptimport { provideHttpClient, withInterceptors } from '@angular/common/http';
import { credentialsInterceptor } from './credentials.interceptor';
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(
withInterceptors([credentialsInterceptor]) // Register it here
)
]
};
2. Individual Request ConfigurationIf you only want to send cookies to specific endpoints,
pass the withCredentials option directly inside your service.
typescriptimport { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class ApiService {
private http = inject(HttpClient);
getData() {
return this.http.get('https://your-api-domain.com', {
withCredentials: true // Enables cookies for this request only
});
}
}