My application is embedded in an iframe, I need to retrieve the url parameters.
I print out the url within the callback that executes when dcc.Location changes url. The main parts of my code are (I skip the definition of some variable for simplicity)
app = dash.Dash(__name__)
server = app.server
app.config["suppress_callback_exceptions"] = True
app.layout = page_builder.page_structure
#...
@app.callback(
dash.dependencies.Output(presentation_constants.PAGE_CONTENTS, "children"),
[dash.dependencies.Input(presentation_constants.URL, "href")],
)
def _my_page(href):
if href is None:
return DEFAULT_OUTPUT
log.info(f"Starting with my page for href {href}") # here I get the correct path but sometimes query parameters are missing!
# ...
page_structure is defined as
page_structure = html.Div(
[
dcc.Location(
id=pc.URL, refresh=False
),
html.Div(id=pc.PAGE_CONTENTS),
]
)
Inspecting the iframe, I can see the correct path; the log in the callback reports the correct path, but the query parameter is stripped. Reloading the page in which the iframe is used, in the log I get the correct query parameters.
Do you see any evident reason for such behavior?