Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The assets server host is inconsistently included in an asset source URL. #417

Closed
mohniaz-com opened this issue Jul 23, 2020 · 3 comments
Closed
Labels
type: bug 🐛 Something isn't working @vendure/core
Milestone

Comments

@mohniaz-com
Copy link

It seems that when directly querying for a product like this:

query {
  product(id: 2) {
    name
    featuredAsset {
      preview
    }
}

The featured asset's preview URL includes the asset server's host. Like this: "http://localhost:3000/assets/source/5a/kelly-sikkema-685291-unsplash.jpg".

But when querying with a search like this:

query allProducts {
  search(input: { groupByProduct: true }) {
    totalItems
    items {
      featuredAsset: productAsset {
        id
        preview
      }
    }
  }
}

The featured asset's preview URL does not include the asset server's host. Like this: "preview/71/derick-david-409858-unsplash__preview.jpg". Which is quite inconsistent and makes the frontend development a bit confusing.

@michaelbromley
Copy link
Member

Thanks for the report. Does it include the host when you don't use an alias in your search query?

@mohniaz-com
Copy link
Author

Yes, it does. Is excluding the host when using an alias the intended effect?

@michaelbromley
Copy link
Member

No, it was just a use-case I did not account for. I'll see if there is a way to make it work when using aliases.

The code that will need to change is this:

if (value.productAsset) {
value.productAsset.preview = toAbsoluteUrl(request, value.productAsset.preview);
}

As you can see it is currently testing the name of the property, and expecting it to be "productAsset"

@michaelbromley michaelbromley added @vendure/core type: bug 🐛 Something isn't working labels Jul 23, 2020
@michaelbromley michaelbromley added this to the v0.14.1 milestone Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working @vendure/core
Projects
None yet
Development

No branches or pull requests

2 participants