Skip to content
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

Packages from the local npm repository with a slash in their names are not loaded #2601

Open
i-interested opened this issue Sep 10, 2024 · 0 comments
Assignees
Labels
Type: Bug Something isn't working

Comments

@i-interested
Copy link

i-interested commented Sep 10, 2024

Describe the bug

I set up verdaccio as a local npm repository, and set up yarp as a proxy. When using verdaccio directly, packages with a slash are downloaded, but not with a proxy

To Reproduce

This behavior is reproduced only on packages where there is a slash in the name or in the dependencies of packages there are packages in the name of which there is a slash. Packages without slashes are downloaded without problems.

  1. Run verdaccio using docker docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
  2. Open or create some frontend project (I use react and yarn) and try add package use local repository yarn add --registry http://localhost:4873 @babel/core . The package will be added.
  3. Create yarp project

code:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddReverseProxy()
    .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();

app.MapReverseProxy();
app.Run();

appsettings:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ReverseProxy": {
    "Routes": {
      "npm": {
        "ClusterId": "cluster-npm",
        "Match": {
          "Hosts": [ "localhost" ],
          "Path": "{**catch-all}"
        },
        "Transforms": [
          { "RequestHeadersCopy": "true" },
          { "RequestHeaderOriginalHost": "true" },
          {
            "X-Forwarded": "Append",
            "HeaderPrefix": "X-Forwarded-"
          }
        ]
      }
    },
    "Clusters": {
      "cluster-npm": {
        "Destinations": {
          "destination1": {
            "Address": "http://localhost:4873"
          }
        }
      }
    }
  }
}
  1. Run proxy and try add package use local repository with proxy yarn add --registry http://localhost:5184 @babel/core . The package will not be added with error
error An unexpected error occurred: "http://localhost:5184/@babel%2fcore: invalid package".

log yarp

info: Yarp.ReverseProxy.Forwarder.HttpForwarder[9]
      Proxying to http://localhost:4873/@babel%252fcore HTTP/2 RequestVersionOrLower
info: Yarp.ReverseProxy.Forwarder.HttpForwarder[56]
      Received HTTP/1.1 response 400.

log verdaccio when use proxy

2024-09-10 11:51:19 info <-- 172.17.0.1 requested 'GET /@babel%252fcore'
2024-09-10 11:51:19 http <-- 400, user: null(::1 via 172.17.0.1), req: 'GET /@babel%252fcore', error: invalid package
2024-09-10 11:51:19 http <-- 400, user: null(::1 via 172.17.0.1), req: 'GET /@babel%252fcore', error: invalid package

log verdaccio without proxy

2024-09-10 11:52:56 info <-- 172.17.0.1 requested 'GET /@babel%2fcore'
2024-09-10 11:52:56 info --- auth/allow_action: access granted to: undefined
2024-09-10 11:52:56 info --- allowed access for @babel/core
2024-09-10 11:52:56 http <-- 200, user: null(172.17.0.1), req: 'GET /@babel%2fcore', bytes: 0/0
2024-09-10 11:52:56 info --- making request: 'GET https://registry.npmjs.org/@babel%2Fcore'
2024-09-10 11:52:57 http --- 304, req: 'GET https://registry.npmjs.org/@babel%2Fcore' (streaming)
2024-09-10 11:52:57 http --- 304, req: 'GET https://registry.npmjs.org/@babel%2Fcore', bytes: 0/0
2024-09-10 11:52:57 http <-- 200, user: null(172.17.0.1), req: 'GET /@babel%2fcore', bytes: 0/117578

Further technical details

@i-interested i-interested added the Type: Bug Something isn't working label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants