NPM Packages published to gitea npm registry which use a scope, can't be opened in the web interface 404 #10004

Closed
opened 2025-11-02 08:55:27 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @suricoon on GitHub (Dec 21, 2022).

Description

Summary

NPM Packages published to gitea npm registry which use a scope, can't be opened in the web interface anymore.
The UI shows 404

Steps to reproduce

  • create any npm project using npm init
  • name the npm project something like @myscope/my-fancy-lib
  • create a local .npmrc and put the registry info there including the scope
  • npm publish the package
  • navigate to the organization/user and open packages tab
  • click on the newly published package
  • you will get a 404

.npmrc

@myscope:registry=https://********/api/packages/myorg/npm/
//********/api/packages/myorg/npm/:_authToken=${NPM_TOKEN}

package.json

{
    "name" : "@myscope/my-fancy-lib"
    ...
}

The problem

image
The @ of the package name does not seem to be URL encoded in the URL.
image
image

Gitea Version

1.17.2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

see description above

Git Version

No response

Operating System

No response

How are you running Gitea?

self hosted gite in a docker container behing reverse proxy nginx

Database

None

Originally created by @suricoon on GitHub (Dec 21, 2022). ### Description ## Summary NPM Packages published to gitea npm registry which use a scope, can't be opened in the web interface anymore. The UI shows 404 ## Steps to reproduce - create any npm project using npm init - name the npm project something like @myscope/my-fancy-lib - create a local .npmrc and put the registry info there including the scope - npm publish the package - navigate to the organization/user and open packages tab - click on the newly published package - you will get a 404 ## .npmrc ```` @myscope:registry=https://********/api/packages/myorg/npm/ //********/api/packages/myorg/npm/:_authToken=${NPM_TOKEN} ```` ## package.json ```` { "name" : "@myscope/my-fancy-lib" ... } ```` ## The problem ![image](https://user-images.githubusercontent.com/49761117/208945265-4221222b-4cae-4388-8a44-37fa6b4ad846.png) The @ of the package name does not seem to be URL encoded in the URL. ![image](https://user-images.githubusercontent.com/49761117/208946035-331a88eb-974d-4614-b133-33a67b59965c.png) ![image](https://user-images.githubusercontent.com/49761117/208945566-ebd850db-418b-4fd3-a177-aa86d48f696f.png) ### Gitea Version 1.17.2 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots see description above ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? self hosted gite in a docker container behing reverse proxy nginx ### Database None
GiteaMirror added the topic/packagesissue/needs-feedback labels 2025-11-02 08:55:27 -06:00
Author
Owner

@KN4CK3R commented on GitHub (Dec 22, 2022):

Still works for me:

@KN4CK3R commented on GitHub (Dec 22, 2022): Still works for me: ![](https://user-images.githubusercontent.com/1666336/209147727-aaf35632-e9f2-4559-96fd-2ff8f9136871.png)
Author
Owner

@KN4CK3R commented on GitHub (Dec 23, 2022):

Maybe same error as #20890 or #21407?

@KN4CK3R commented on GitHub (Dec 23, 2022): Maybe same error as #20890 or #21407?
Author
Owner

@cedx commented on GitHub (Jan 1, 2023):

Same issue here. Using Gitea 1.18.0 with SQL Server 2019 on Windows Server 2019.

@cedx commented on GitHub (Jan 1, 2023): Same issue here. Using Gitea 1.18.0 with SQL Server 2019 on Windows Server 2019.
Author
Owner

@KN4CK3R commented on GitHub (Jan 1, 2023):

Which reverse proxy do you use?

@KN4CK3R commented on GitHub (Jan 1, 2023): Which reverse proxy do you use?
Author
Owner

@cedx commented on GitHub (Jan 1, 2023):

You've found the root cause: thank you @KN4CK3R ! I've tried a direct access (i.e. without using the proxy), and it works!

I'm using Microsoft IIS with the Application Request Routing & Rewrite modules. Now I just have to figure out how to properly configure IIS...

My current web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<system.webServer>
		<httpErrors existingResponse="PassThrough"/>
		<rewrite>
			<rules>
				<clear/>
				<rule name="Proxy" patternSyntax="Wildcard" stopProcessing="true">
					<match url="*"/>
					<action type="Rewrite" url="http://127.0.0.1:9000/{R:1}"/>
				</rule>
			</rules>
		</rewrite>
	</system.webServer>
</configuration>
@cedx commented on GitHub (Jan 1, 2023): You've found the root cause: thank you @KN4CK3R ! I've tried a direct access (i.e. without using the proxy), and it works! I'm using Microsoft IIS with the Application Request Routing & Rewrite modules. Now I just have to figure out how to properly configure IIS... My current `web.config`: ```xml <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <httpErrors existingResponse="PassThrough"/> <rewrite> <rules> <clear/> <rule name="Proxy" patternSyntax="Wildcard" stopProcessing="true"> <match url="*"/> <action type="Rewrite" url="http://127.0.0.1:9000/{R:1}"/> </rule> </rules> </rewrite> </system.webServer> </configuration> ```
Author
Owner

@cedx commented on GitHub (Jan 1, 2023):

With IIS, you can avoid this issue by disabling the useOriginalURLEncoding flag and using the UNENCODED_URL server variable:

<rules useOriginalURLEncoding="false">
	<clear/>
	<rule name="Proxy" patternSyntax="Wildcard" stopProcessing="true">
		<match url="*"/>
		<action type="Rewrite" url="http://127.0.0.1:9000{UNENCODED_URL}"/>
	</rule>
</rules>

So definitely a proxy issue on my side.

@cedx commented on GitHub (Jan 1, 2023): With IIS, you can avoid this issue by disabling the `useOriginalURLEncoding` flag and using the `UNENCODED_URL` server variable: ```xml <rules useOriginalURLEncoding="false"> <clear/> <rule name="Proxy" patternSyntax="Wildcard" stopProcessing="true"> <match url="*"/> <action type="Rewrite" url="http://127.0.0.1:9000{UNENCODED_URL}"/> </rule> </rules> ``` So definitely a proxy issue on my side.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10004