-
Notifications
You must be signed in to change notification settings - Fork 971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Page Not Found" after deploying SSR enabled Angular 17 application #6505
Comments
Found the solution: angular/angularfire#3463 (comment) |
@misomarcell Is not a solution is the old way to use the builder. Angular v17 came with the new builder (see https://angular.dev/tools/cli/build):
That's why you don't need to separate de browser & server builders. |
@hittten The new approach of building the application in a bundle currently does not work with the Firebase deployment, that's why we need to separate the browser and the server. If you have a better solution to this problem, please educate us. |
This problem also occurs with non-SSR angular apps starting in v17. I suspect the reason is that in v17, a newly scaffolded app puts it build output in a different path. Old : This is because, as hinted in the linked issue, a newly scaffolded app uses a new builder in Old: A commenter on the linked issue shows they were able to fix it by reverting back to the old builder. The tooling needs to update to support the new builder. I'm not sure if that's the responsibility of this repo, or angularfire. |
I don't have the solution we have to wait for firebase-tools to make the fix to unterstand the new builder for angular 17: https://esbuild.github.io/ Let's see, I said that it was not a solution because in Angular 17 you can actually use the previous build. So if you really want to use the new build which is much faster and better than webpack, we don't have a solution/workaround for this yet. There are two problems here:
{
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/myApp/browser",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/myApp/server",
"main": "server.ts",
"tsConfig": "tsconfig.server.json",
"inlineStyleLanguage": "scss"
},
"configurations": {
"production": {
"outputHashing": "media"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"sourceMap": true,
"extractLicenses": false,
"vendorChunk": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.development.ts"
}
]
}
},
"defaultConfiguration": "production"
},
"prerender": {
"builder": "@nguniversal/builders:prerender",
"options": {
"guessRoutes": false,
"routes": [
"/"
]
},
"configurations": {
"production": {
"browserTarget": "myApp:build:production",
"serverTarget": "myApp:server:production"
},
"development": {
"browserTarget": "myApp:build:development",
"serverTarget": "myApp:server:development"
}
},
"defaultConfiguration": "production"
}
}
As you can see, we have 3 builders here: {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/myApp/browser"
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/myApp/server"
}
},
"prerender": {
"builder": "@nguniversal/builders:prerender",
"options": {
"guessRoutes": false,
"routes": [
"/"
]
}
}
}
The "output path" determines where the correct folder is for each build: "browser" and "server". If you visit your hosting URL, "/browser", you will see the files, but with errors. Now in angular 17 with the "@angular-devkit/build-angular:application" builder, the "angular.json" file should be simplified, but firebase-tools doesn't know how to handle it.
|
@ersimont angularfire is not necessary for a Firebase web framework with SSR deploy. You can see this: https://firebase.google.com/docs/hosting/frameworks/angular The AngularFire is optinal I have many websites with the minimal for SSR, you can try it: npm i -g @angular/cli@16 @firebase-tools With this you should have an Angular application with firebase hosting and a ssr cloud function v2 (Cloud run) |
@jamesdaniels does this PR fix this issue? I'm having the same problem on angular 17. |
Angular v17 & application builder support is landing with #6480 |
Hi, I'm noob but this solution seems to work : 1. Your public directory is the folder (relative to your project directory) that ? What do you want to use as your public directory? dist/myapp/browser => firebase.json 3. |
@robin-james Doing this, you serve the application statically, but does not enable SSR |
How can I check if the SSR is working ? When I inspect the source code (ctrl+u) all the html appears correctly h1 etc... This was not the case with the old versions it seems to me. |
You might have prerender enabled (it is by default) Set prerender to false in your angular.json and try again. Note that if you don't have dynamic server side logic (based on auth cookie for instance) you might just go with your setup |
If anyone wants to try the upcoming support for Angular 17 SSR Apps and can not wait for an official release, you can use |
@sonallux thank you with your trick I was able to deploy on firebase it looked ok but it was only pre-rendering that was fine |
I had the same issue. You must remove the |
@sonallux thank you again and you seems to understand angular SSR pretty well. So I assume that because under the hood the directus/sdk do not use anything related to angular SSR is not kicking in. Any suggestion on how I could include standard library in the SSR process ? |
Seems like after installing the version of the |
Hi @misomarcell, I've a question, are you deploying |
The problem is that the request is not executed in a macro task through Zone.js. See this Stack overflow answer for more details. |
Closing this issue as v17 support has landed on latest |
[REQUIRED] Environment info
firebase-tools: 12.8.1
@angular/core: "^17.0.1
@angular/common: "^17.0.1
@angular/compiler: "^17.0.0
@anguler/ssr: 17.0.0
Platform: Windows 11, 23H2
[REQUIRED] Test case
See the full repository here: https://github.com/misomarcell/fire-chat
firebase.json
angular.json
[REQUIRED] Steps to reproduce
ng new
@angular/fire@17.0.0-next.0
firebase experiments:enable webframeworks
firebase init
firebase deploy
[REQUIRED] Expected behavior
A server-side rendered website loads when opening firebase web app.
[REQUIRED] Actual behavior
Page Not Found error displayed when opening the firebase web app.
Additional info
ng serve
and using the hosting emulator./browser
loads the index.html, but due to 404, it can't load any of the assets, like js and css files, therefore it's just an empty white page without any content on it whatsoever.The text was updated successfully, but these errors were encountered: