Absolute URLs in decorateWidget API being rewritten

This seems like it could be a subdirectory bug. With the code below, a button is generated in the header to the specifications, including in the HTML, but rather than being taken to /donate when clicked, users are instead taken to /community/donate.

api.decorateWidget('header-buttons:after', helper => {
    return helper.attach('link', {
        className: 'btn-primary btn-small login-button donate-button',
        icon: 'paypal',
        rawLabel: "Donate",
        href: "https://critcola.com/donate"
    });
});
2 Likes

The link widget is specifically meant to route within the discourse app, so in this case it thinks /donate is a path within the forum. Instead you could just make your link manually like this:

api.decorateWidget('header-buttons:after', helper => {
    return helper.h('a', {
        className: 'btn-primary btn-small login-button donate-button',
        attributes: { href: 'https://critcola.com/donate', target: '_blank' },
    }, [helper.h('i.fa.fa-paypal'), ' Donate'])
});
6 Likes

Good to know. Thanks!

1 Like