Skip to content

passthrough service worker can break sites using redirected stylesheets #757

Closed
@wanderview

Description

@wanderview

Consider a site a.com which has a stylesheet link to a.com/foo.css. But a.com/foo.css redirects to a.com/style/foo.css. Inside foo.css there is a relative background-image url to ./bg.jpg.

With no service worker in play, the site will end up loading a.com/style/bg.jpg.

If there is a passthrough service worker that does nothing but e.respondWith(fetch(e.request)); then the site will try to load a.com/bg.jpg. This is because the redirect to a.com/style/foo.css is eaten by the SW fetch() call.

Should FetchEvent.request for stylesheet loads have RequestRedirect set to "manual"? This would ensure that the stylesheet always sees the final URL and properly loads the correct relative sub-resources.

cc @jakearchibald @slightlyoff @annevk

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions