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

send HTTP request from external app to this app #1337

Closed
tuanda-mh opened this issue Aug 28, 2024 · 5 comments
Closed

send HTTP request from external app to this app #1337

tuanda-mh opened this issue Aug 28, 2024 · 5 comments

Comments

@tuanda-mh
Copy link

Hi, when I created this issue earlier, you guys told me to add my route before the line:
app.use("/api/*", shopify.validateAuthenticatedSession());
and it will work. But when I did that and sent the request via Postman, it still returned this:

<script type="module"> import RefreshRuntime from "/@react-refresh" RefreshRuntime.injectIntoGlobalHook(window) window.$RefreshReg$ = () => {} window.$RefreshSig$ = () => (type) => type window.__vite_plugin_react_preamble_installed__ = true </script>
<script type="module" src="/@vite/client"></script>

<meta charset="UTF-8" />

<!-- Ensures that the UI is properly scaled in the Shopify Mobile app -->
<meta name="viewport" content="width=device-width, initial-scale=1">

<script type="module" src="/index.html?html-proxy&index=0.js"></script>

<meta name="shopify-api-key" content="969243d7931c14f508e083be7dea7a9d" />
<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js"></script>
<script type="module" src="/index.jsx"></script>
@tuanda-mh
Copy link
Author

please help

@tuanda-mh
Copy link
Author

I used the following url to send my request:
app-url/route

@paulomarg
Copy link
Collaborator

paulomarg commented Aug 28, 2024

Sorry, I misunderstood your last question!

I think the problem might be that in development, your request will hit the frontend vite server first, so you'll need to add a proxy for the route you're using.

Probably something like this in your vite.config file:

    proxy: {
      "^/(\\?.*)?$": proxyOptions,
      "^/api(/|(\\?.*)?$)": proxyOptions,
+      "^/route(/|(\\?.*)?$)": proxyOptions,
    },

Hope this helps!

@tuanda-mh
Copy link
Author

this solved my issue, thank you very much

@paulomarg
Copy link
Collaborator

Happy to hear that, sorry for the confusion :)

Closing the issue then!

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

2 participants