mirror of
https://github.com/vee1e/bulk-questionnaire-upload.git
synced 2026-09-01 09:50:06 +00:00
fix: skip loadForms during SSR to prevent localhost fallback error
During server-side rendering main.ts never runs, so loadRuntimeConfig() is never called and apiUrl falls back to localhost:8000. The failed HTTP call triggers the error snackbar during client hydration. Guard loadForms with isPlatformBrowser so it only runs in the browser where the config is correctly loaded. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b9bf24ef71
commit
252cb503fe
1 changed files with 7 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnInit, Input, OnChanges, SimpleChanges, HostListener } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, OnInit, Input, OnChanges, SimpleChanges, HostListener, PLATFORM_ID, inject } from '@angular/core';
|
||||
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
|
@ -1593,10 +1593,14 @@ export class UploadComponent implements OnInit, OnChanges {
|
|||
currentPreviewedFormId: string | null = null;
|
||||
updateTargetForm: FormData | null = null;
|
||||
|
||||
private platformId = inject(PLATFORM_ID);
|
||||
|
||||
constructor(private formService: FormService, private formPreviewService: FormPreviewService, private snackBar: MatSnackBar) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadForms();
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
this.loadForms();
|
||||
}
|
||||
this.restoreUploadState();
|
||||
|
||||
// Subscribe to currently previewed form
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue