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

Missing support for programmatic top-level external navigation #462

Open
mathhulk opened this issue Jan 27, 2025 · 0 comments
Open

Missing support for programmatic top-level external navigation #462

mathhulk opened this issue Jan 27, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@mathhulk
Copy link

mathhulk commented Jan 27, 2025

Describe the bug

@shopify/[email protected] provided a useNavigate hook permitting programmatic top-level external navigation without requiring user interaction:

const navigate = useNavigate();

useEffect(() => navigate(`https://external.com/api/oauth/shopify${location.search}`), []);

Such navigation enables external authorization.

Unfortunately, no such navigation seems to be available for @shopify/[email protected].

The following cases results in a cross-origin resource sharing (CORS) error, but seem to be the recommended use cases according to the documentation:

useEffect(() => window.open(`https://external.com/api/oauth/shopify${location.search}`, "_top"), []);
useEffect(() => window.top.location.href = `https://external.com/api/oauth/shopify${location.search}`;
useEffect(() => {
  const anchor = document.createElement("a");
  anchor.href = `https://external.com/api/oauth/shopify${location.search}`;
  anchor.target = "_top";
  
  anchor.click();
}, []);

To Reproduce

Implement any of the above examples.

Expected behaviour

Programmatic top-level external navigation should be permitted.

Contextual information

Packages and versions

List the relevant packages you’re using, and their versions. For example:

  • @shopify/app-bridge-react @ 4.X.X

Platform

  • OS: macOS
  • OS Version: 15.0
  • App: Chrome

Additional context

I am using Vite and React.

@mathhulk mathhulk added the bug Something isn't working label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant