Skip to content

Development and Production differs on entry '/' #29012

Closed

Description

@alexandresebrao

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

19.0.0

Description

On development mode I'm not having any problem when using AppNodeEngine

But when in production when accessing the root is not working the same way.

On my test I'm having a problem with angularNodeAppEngine

Minimal Reproduction

The example uses fastify

    server.get('*', async (req, reply) => {
       const user = {username: 'test'}
        try {
            const response = await angularNodeAppEngine.handle(req.raw, {
                user
            })
            if (response) {
                console.log(" i'm here ")
                await writeResponseToNodeResponse(response, reply.raw)
            } else {
                reply.callNotFound()
            }
        } catch (error) {
            reply.send(error)
        }
    })

If i hit any route like
/profile

The console will say 'im here'

And everything will work fine.

But with /

It will not

With this my canActivate wont receive the REQUEST_CONTEXT of the user and will redirect him to the login page, instead of the homepage
app.server.route.ts


export const serverRoutes: ServerRoute[] = [
    {
        path: '**',
        renderMode: RenderMode.Server
    }
]```


### Exception or Error

```text

Your Environment

Angular CLI: 19.0.2
Node: 22.11.0
Package Manager: pnpm 9.13.2
OS: linux x64

Angular: 19.0.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... localize, material, material-luxon-adapter, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1900.2
@angular-devkit/core         19.0.1
@angular-devkit/schematics   19.0.1
@angular/build               19.0.2
@angular/cli                 19.0.2
@angular/ssr                 19.0.2
@schematics/angular          19.0.1
rxjs                         7.8.1
typescript                   5.6.3
zone.js                      0.15.0

Anything else relevant?

I didn't make the mini repo, but if its really needed I will send as soon as possible, any other info I will be pretty happy to share.

Activity

  1. alan-agius4 commented on Dec 2, 2024

    @alan-agius4
    Collaborator

    Hi @alexandresebrao, I tried this locally and I was not able to replicate the mentioned behaviour. Can you setup a minimal repro please?

    You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

    This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

  2. added
    needs: repro steps
    on Dec 2, 2024
  3. alexandresebrao commented on Dec 2, 2024

    @alexandresebrao
    Author

    Okay, Figure out the problem:

    Using custom index is the problem.

              "index": {
                "input": "src/index.prod.html",
                "output": "index.html"
              },
    

    In prod we add Microsoft Clarity

    https://github.com/alexandresebrao/AngularCustomIndex

  4. added
    freq1: low
    and removed
    needs: repro steps
    on Dec 3, 2024
  5. self-assigned this
    on Dec 3, 2024
  6. added 4 commits that reference this issue on Dec 3, 2024
    b5f1310
    17ee61f
    51371f1
    d0355f1
  7. added 2 commits that reference this issue on Dec 3, 2024
    97897b7
    21f21ed
  8. angular-automatic-lock-bot commented on Jan 3, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  9. locked and limited conversation to collaborators on Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

angular/build:applicationarea: @angular/buildfreq1: lowseverity3: brokentype: bug/fix

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions