-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Running local server on non-localhost causes breakages #12054
Comments
looking |
I believe this is stemming from the hardcoded check for |
Another option is to force |
this also complicates it: https://github.com/ampproject/amphtml/blob/master/src/3p-frame.js#L235 |
@erwinmombay Are you working on a fix? If not, I'm happy to pick this up. |
@bradfrizzell @erwinmombay I just sent out a fix for this in #12152. Once merged, the following will no longer result in 404s when you load
Note that for the ads to actually be served in this scenario, you'll probably have to change how |
After merging #12152, a couple of hidden bugs in
A workaround for 1 is to run these commands, after which the page will load correctly:
@bradfrizzell assigning this back to you for further investigation. |
I have a fix (for item 1 in #12054 (comment)) out for review at #12458 |
@bradfrizzell Assigning this back to you for item 2 in #12054 (comment), where |
@rsimha-amp shall we completely remove any hardcoded That makes sure AMP runtime can be run under any domain in dev mode, which is sometimes very helpful if we want to locally fake the CDN domain and test CORS related logic (like A4A fast fetch). |
@lannka I originally removed the I do agree though, that it makes sense to simplify the logic in |
const FORCE_LOCALDEV = !!(self.AMP_CONFIG && self.AMP_CONFIG.localDev);
const AMP_CONFIG_3P_FRAME_HOST = self.AMP_CONFIG &&
self.AMP_CONFIG.thirdPartyFrameHost;
const isLocalDev = IS_DEV
&& !!(win.location.hostname == 'localhost'
|| (FORCE_LOCALDEV && win.location.hostname == AMP_CONFIG_3P_FRAME_HOST)
|| (win.location.ancestorOrigins && win.location.ancestorOrigins[0] && startsWith(win.location.ancestorOrigins[0], 'http://localhost:'))
)
&&
// Filter out localhost running against a prod script.
// Because all allowed scripts are ours, we know that these can only
// occur during local dev.
(!win.document || !!win.document.querySelector(developmentScriptQuery)); This is the current I want to simplify this to: const isLocalDev = IS_DEV && FORCE_LOCALDEV; And let our gulp build or gulp server to always append |
@lannka i honestly don't remember why we need all the |
Thanks @erwinmombay . I tested the proposed change, once we prepend AMP_CONFIG to amp.js, the ads examples start to work. However, right now I have to do:
It does not work if I ran the local server using:
@rsimha-amp can we make build with "--config=canary" the default? |
We use |
@lannka do both sets of steps in #12458 (comment) work with your change? What about the steps in #12054 (comment)? And what about Heroku? I believe some of those conditions were put in to make all these scenarios work. I like your fix though, so let me know how I can help to make it real :) |
I think I think the fix should be in gulpfile.js. Currently the default |
@bradfrizzell Now that the
... and navigate to I think if we change src/3p-frame.js to return Just sent out #12673 with a fix. |
Reopening based on #12666 and #12673 (comment) |
Paging @erwinmombay @lannka @ampproject/a4a :) After debugging, I'm seeing that In other words,
Presumably, this is because the AMP config overrides aren't being applied to the 3rd party frame, which is probably why non-localhost scenarios never did work.
|
Turns out we need to write |
Steps to reproduce:
navigate to hostname:8000/examples/ads.amp.html
Select doubleclick for ad network.
Notice how all the ads 404
The issue is that non-localhost is not being identified as localDev in mode.js, which is instead hardcoding localhost in its check for localdev mode.
The text was updated successfully, but these errors were encountered: