Proxied Strapi + NextJS with Nginx is not working well

I have a NextJS frontend and a Strapi backend running on an Ubuntu box proxied with Nginx. I have set /strapi subfolder as the location for all strapi requests as per the following config:

location /strapi/ {
rewrite ^/strapi/?(.*)$ /$1 break;
proxy_pass http://localhost:1337/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location / {
proxy_pass http://localhost:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

This works fine for proxying all backend requests, and works locally on my machine, as Nginx strips away /strapi and redirects all queries to /api/articles, for example.

However, this fails on the frontend side - Nginx is stripping away /strapi from URL’s correctly, but for some reason the essential scripts are still located at /strapi/admin and so the panel doesn’t get loaded.
GET
https://mydomain.com/admin/runtime~main.6e4d1d4c.js
[HTTP/1.1 404 Not Found 168ms]

GET
https://mydomain.com/admin/main.8b078a8a.js