webrecorder / pywb

Core Python Web Archiving Toolkit for replay and recording of web archives
https://pypi.python.org/pypi/pywb
GNU General Public License v3.0
1.41k stars 217 forks source link

PyWB 2.6.2 ignoring SCRIPT_NAME when deployed under a prefix #686

Closed anjackson closed 2 years ago

anjackson commented 2 years ago

Describe the bug

Even after 2.6.2 #682, static resources are not being loaded when PyWB is deployed under a prefix. We deploy PyWB under e.g. /wayback/ so the static resources are at /wayback/static/. For 2.5.x this is picked up by the SCRIPT_NAME UWSGI parameter, but this is ignored by 2.6.2.

EDIT: Ah, so this is not really to do with static resources - the whole app does not realize it is deployed under a prefix and doesn't work at all for us.

Config is at:

Steps to reproduce the bug

Deploy under a prefix

Expected behavior

Application uses supplied prefix as the deployment prefix.

Screenshots

Environment

Based on container version webrecorder/pywb:2.6.2

Additional context

anjackson commented 2 years ago

For context, I had to change template escaping when going from PyWB 2.5.x to 2.6.x (see here) but otherwise the UKWA extension code is unchanged.

I did not have to set the static path before, and I don't know how to set it.

anjackson commented 2 years ago

The only thing I can find is:

https://github.com/webrecorder/pywb/blob/e64e58f04010d333e088b9deef0a4893cf549069/pywb/rewrite/templateview.py#L325

But I can't set pywb.static_prefix as an environment variable (because you're not supposed to put a . in an environment variable name and so the deployment system won't let me set it).

Also, I think the default should be {{wb_prefix}}/static not just /static.

Setting static_prefix in `conf`` is just ignored.

anjackson commented 2 years ago

Ah, okay, so there's a difference between different pages. The actual playback pages are working fine, and pick up the right prefix automatically, and also pick up the static_prefix setting (which actually breaks things in this case).

It's the 'index' pages that have problems. e.g. the page that lists collections has no CSS/JS, and the Collection Search page too. But the Calendar and the playback itself are fine.

ikreymer commented 2 years ago

Should be fixed in 2.6.3, should not need to set the static path or any additional changes.