imgix / gatsby

A simple yet powerful integration between Gatsby and imgix
BSD 2-Clause "Simplified" License
30 stars 6 forks source link

fix: Invalid plugin options for "@imgix/gatsby" - "domain" is required #254

Closed arsinclair closed 1 year ago

arsinclair commented 1 year ago

We're upgrading from v2.0.3 to v2.0.4 of this library and we started receiving such error on gatsby develop:

success load gatsby config - 0.088s ERROR #11331 PLUGIN Invalid plugin options for "@imgix/gatsby":

  • "domain" is required

The release notes for v2.0.4 doesn't list any changes in the way how the domain setting logic is handled, which makes us think that this is a bug.

This is the configuration we use:

{
    resolve: "@imgix/gatsby",
    options: {
        domain: "", // keep it empty, since we want to preserve domain name together with the link
        sourceType: ImgixSourceType.AmazonS3,
        fields: [
            {
                nodeType: "ImagesJson",
                rawURLKey: "url",
                fieldName: "image"
            }
        ],
        disableIxlibParam: true
    }
}

We intentionally set domain to be empty because we want to keep the full URL of our imgix images in our components.

The README.md states:

If url is: an imgix URL, domain and secureURLToken are likely not required. If domain is set, the source must be a Web Proxy Source. If "secure URLs" are enabled on the imgix source, or the source is a Web Proxy Source, secureURLToken is required.

We tried removing the domain parameter from the config entirely as the docs suggest that it's optional, but we receive the same error.

What can be done about this? Thank you in advance!

luqven commented 1 year ago

Hey @arsinclair, thanks for opening this issue.

This does seem like a bug, domain should have remained optional. I can't give you a time estimate yet, but we'll investigate and update this ticket.

arsinclair commented 1 year ago

Hi, has there been any progress with this issue? It prevents us from upgrading the plugin further and it also prevents us from migrating to Gatsby v5.

luqven commented 1 year ago

Hey @arsinclair , my apols for the delay here.

We ran into a blocker with our E2E tests, the setup there isn't ideal and needs to be fixed. That held this fix back longer than it probably should have.

261 should have addressed this issue.

This issue was caused by our refactoring away from FPTS and to Joi schemas. We inadvertently set domain as required when this refactoring took place. You will now be able to entirely omit the domain field rather than having to set it to an empty string.

{
    resolve: "@imgix/gatsby",
    options: {
        // don't set `domain` at all, if you use absolute URLs you won't need it
        sourceType: ImgixSourceType.AmazonS3,
        fields: [
            {
                nodeType: "ImagesJson",
                rawURLKey: "url",
                fieldName: "image"
            }
        ],
        disableIxlibParam: true
    }
}

You can try this out on @imgix/gatsby@next or this CodeSandbox. Note, the sandbox serves an example app from test/dev-and-e2e.

Please do let us know if this doesn't address the problem and we'll be happy to look into it. We plan to cut a release with this fix soon.

arsinclair commented 1 year ago

Thanks @luqven, I just tested @imgix/gatsby@next and it works fine!

imgix-git-robot commented 1 year ago

:tada: This issue has been resolved in version 2.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: