Skip to content

Update app proxy url in dev, when specified in config as code#2594

Merged
Arkham merged 2 commits intomainfrom
update-app-proxy-url-in-dev
Aug 4, 2023
Merged

Update app proxy url in dev, when specified in config as code#2594
Arkham merged 2 commits intomainfrom
update-app-proxy-url-in-dev

Conversation

@Arkham
Copy link
Contributor

@Arkham Arkham commented Aug 2, 2023

WHY are these changes introduced?

We allow developers to setup an app proxy, which is composed of:

  • proxy url (e.g. https://my-cool-shopify-app.com)
  • proxy subpath prefix (e.g. apps)
  • proxy path (e.g. my-cool-proxy)

If they set it up, every time a user visits https://fancy-apparel.myshopify.com/apps/my-cool-proxy/another-path we will forward them to https://my-cool-shopify-app.com/another-path.

The issue is that while running app dev, if you accept to automatically update URLs, we will spawn a cloudflare tunnel and use it to automatically update:

  • your application url
  • your auth redirect urls

But we won't automatically update your app proxy url.

With the introduction of config as code, the workaround is to update the shopify.app.toml yourself and run app config push, but it's still not great.

WHAT is this pull request doing?

If all the following applies:

  • config as code is enabled
  • the app_proxy section is present
  • you have opted in the automatic update of URLs in dev

THEN we will automatically use the tunnel URL to populate your app proxy URL.

Fixes #990

How to test your changes?

  • bin/create-test-app.js -e ui (when asked if you want to automatically update URLs accept)
  • go to your partners dashboard and fill in your app proxy section
  • go inside the app folder on your desktop and rerun npm run shopify app config link
  • now run npm run dev again, you should see the new url populating:
    • application_url
    • auth.redirect_urls
    • app_proxy.url

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've made sure that any changes to dev or deploy have been reflected in the internal flowchart.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2023

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/theme-code-tools
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/cli-foundations

@Arkham Arkham force-pushed the update-app-proxy-url-in-dev branch from ed29cfe to a01abb5 Compare August 2, 2023 16:11
@Arkham Arkham force-pushed the update-app-proxy-url-in-dev branch from a01abb5 to 6652304 Compare August 2, 2023 16:17
@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2023

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
74.38% (-0.03% 🔻)
5814/7817
🟡 Branches
71.36% (+0.03% 🔼)
2851/3995
🟡 Functions
73.09% (-0.01% 🔻)
1480/2025
🟡 Lines
75.91% (-0.03% 🔻)
5522/7274
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app.ts
82.05% (-6.35% 🔻)
53.33% (-4.36% 🔻)
81.82%
85.51% (-7.83% 🔻)
🔴
... / dev.ts
10.84%
4.88% (-0.08% 🔻)
12.5% 11.81%
🟢
... / ConcurrentOutput.tsx
96.3% (-1.85% 🔻)
83.33% (-4.17% 🔻)
95%
97.96% (-2.04% 🔻)

Test suite run success

1394 tests passing in 660 suites.

Report generated by 🧪jest coverage report action from 77708e3

@Arkham Arkham marked this pull request as ready for review August 3, 2023 13:18
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2023

We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

@Arkham Arkham added this pull request to the merge queue Aug 4, 2023
Merged via the queue into main with commit 3b7214f Aug 4, 2023
@Arkham Arkham deleted the update-app-proxy-url-in-dev branch August 4, 2023 09:50
@shopify-shipit shopify-shipit bot temporarily deployed to nightly August 4, 2023 12:12 Inactive
@BaggioGiacomo
Copy link

BaggioGiacomo commented Aug 21, 2023

Hi @Arkham,
first of all, thanks for this PR and for enhancing the developers experience with app proxy.

I think that one step is missing here (or I've misunderstood something): the app proxy url doesn't change on the .toml file automatically (with the new generated cloudflare url) when starting the dev server.

The application_url and the redirect_urls are being correctly updated tho

@Arkham
Copy link
Contributor Author

Arkham commented Aug 22, 2023

hey @BaggioGiacomo, this PR does that exactly that, it will be released in the next 3.49.x stable release. If you want to test it out in advance, you can update your @shopify/app and @shopify/cli packages to one of the nightly releases here: https://www.npmjs.com/package/@shopify/app?activeTab=versions

@BaggioGiacomo
Copy link

oh, I thought this feature was already released on the 3.48.3, thank you! 🙏🏻

@shopify-shipit shopify-shipit bot temporarily deployed to production September 6, 2023 13:17 Inactive
@andershagbard
Copy link

Why doesn't the app_proxy.url allow a relative URL? webhooks.subscriptions.uri does.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Update proxy app URL

5 participants