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

GroundPolylinePrimitive._initializeTerrainHeightsWorker fails when app is served via a proxied domain #6711

Closed
madole opened this issue Jun 21, 2018 · 5 comments

Comments

@madole
Copy link

madole commented Jun 21, 2018

GroundPolylinePrimitive._initializeTerrainHeightsWorker tries to load in the approximateTerrainHeights.json from a relative path.

GroundPolylinePrimitive.js

ApproximateTerrainHeights.initialize('../Assets/approximateTerrainHeights.json')

This then calls the buildModuleUrl function with that path before passing it to Resource.fetchJson

ApproximateTerrainHeights.js

ApproximateTerrainHeights._initPromise = Resource.fetchJson(buildModuleUrl(url)).then(function(json) {
            ApproximateTerrainHeights._terrainHeights = json;
        });

buildModuleUrl first does a check to see if it's running in node by checking typeof document === 'undefined' and if true, it just returns moduleID.

When inside a web worker, document is undefined and the relative path is returned as it would be in node. This is fine when the code is being accessed on the same domain as it's being served on.

But when you proxy the app, the relative path becomes http://proxied-url.com/../Assets/approximateTerrainHeights.json which doesn't exist as the JSON is being served on a different domain and so the Resource.fetchJson blows up.

@hpinkos
Copy link
Contributor

hpinkos commented Jun 21, 2018

Thanks for catching this before it went out in the release @madole! I've opened up a pull request fixing it here: #6715

@likangning93
Copy link
Contributor

likangning93 commented Jun 21, 2018

@madole @hpinkos does this also apply to non-worker requests for the terrain heights JSON too?
Seems like that would be asking for just http://proxied-url.com/Assets/approximateTerrainHeights.json, which presumably also doesn't exist.

[EDIT] ah I also don't know how buildModuleUrl works, so it might be getting handled in there already.

@madole
Copy link
Author

madole commented Jun 22, 2018

yeah it's handled in buildModuleUrl, because the non-worker context would have document in scope, it'll build the path using CESIUM_BASE_PATH so it's just the workers that have the issue

@mramato
Copy link
Contributor

mramato commented Jun 28, 2018

Replaced by #6720 (though I'm going to keep this branch around until that one gets merged).

@mramato mramato closed this as completed Jun 28, 2018
@mramato mramato reopened this Jun 28, 2018
@mramato
Copy link
Contributor

mramato commented Jun 28, 2018

Whoops, meant to comment on the PR not the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants