I’m currently running an angular 18 SSR app in mi local machine; my app consumes a graphql api using apollo.
I haven’t errors with the functionality but when i check in the browser, in the inspections tool in network (fetch), i see the api graphql consume and i understand when an app is SSR, that type of consume must not appear in network browser, the another problem is when in the browser i disable javascript, the app SSR functionality doesn’t works; then my app angular SSR is working bad or i’m not having another concept in mind?.
Maybe because in my app i configure the access to the localstorage of the user with this?
BrowserStorageService.ts:
import { Inject, Injectable, InjectionToken } from '@angular/core';
export const BROWSER_STORAGE = new InjectionToken<Storage>('Browser Storage', {
providedIn: 'root',
factory: () => localStorage,
});
@Injectable()
export class BrowserStorageService {
constructor(@Inject(BROWSER_STORAGE) public storage: Storage) {}
get(key: string) {
return this.storage.getItem(key);
}
set(key: string, value: string) {
this.storage.setItem(key, value);
}
remove(key: string) {
this.storage.removeItem(key);
}
clear() {
this.storage.clear();
}
}
app.config.server.ts:
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
import { provideServerRendering } from '@angular/platform-server';
import { appConfig } from './app.config';
import { BrowserStorageService } from '@core/services/browser-storage.service';
import { BrowserStorageServerService } from '@core/services/browser-storage-server.service';
const serverConfig: ApplicationConfig = {
providers: [
provideServerRendering(),
{
provide: BrowserStorageService,
useClass: BrowserStorageServerService,
}
]
};
export const config = mergeApplicationConfig(appConfig, serverConfig);