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

Use non-canonical URL for local non-model assets #6082

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/media-url-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const scaledThumbnailUrlFor = (url, width, height) => {
};

export const isNonCorsProxyDomain = hostname => {
return nonCorsProxyDomains.find(domain => hostname.endsWith(domain));
return !!nonCorsProxyDomains.find(domain => hostname.endsWith(domain));
};

export const proxiedUrlFor = url => {
Expand Down
5 changes: 2 additions & 3 deletions src/utils/media-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,9 @@ export async function resolveMediaInfo(urlString) {

// We want to resolve and proxy some hubs urls, like rooms and scene links,
// but want to avoid proxying assets in order for this to work in dev environments
const isLocalModelAsset =
isNonCorsProxyDomain(url.hostname) && (guessContentType(url.href) || "").startsWith("model/gltf");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnshaughnessy do you have any memory of why models were the only local assets that don't use a canonical URL? With the newLoader path - uploaded images, movies, and sounds are broken links when working in a local dev env.

I know this line also appears in "components/media-loader.js" which dates back to this PR.

If I make the change shown here then all media tested (glb, mp3, mp4, jpg) work with newLoader in local dev and on my personal instance. That said, I am unsure of the original intent in having non-model assets use canonical urls and don't want to introduce a regression.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking you specifically because you were the last to work on this section. It was 9 months ago though so no worries if you don't remember.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, unfortunately no. I don't know why we made an exception only for models. But, given that we're OK with the exception for models, I can't think of why we wouldn't be OK to lift the restriction for other media types like videos and images.

At the risk of some regression, I'll go ahead with this PR (despite not understanding what lies on the other side of the fence).

const isLocalAsset = isNonCorsProxyDomain(url.hostname);

if (url.protocol != "data:" && url.protocol != "hubs:" && !isLocalModelAsset) {
if (url.protocol != "data:" && url.protocol != "hubs:" && !isLocalAsset) {
const response = await resolveUrl(url.href);
canonicalUrl = response.origin;
if (canonicalUrl.startsWith("//")) {
Expand Down
Loading