Skip to content

Commit

Permalink
chore: update blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
cvgellhorn committed Nov 18, 2024
1 parent f5b59a4 commit 0944ef0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/content/blog/2024-11-18-checkout-ui-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,17 @@ import fs from "node:fs/promises";

const TARGET_FILE_PATH = "../extensions/your-ext/src/utils/base-url.js";

const writeExtensionAppUrl = async () => {
// Add localhost if SHOPIFY_APP_URL is not set, Shopify defined fallback
const baseUrl = process.env.SHOPIFY_APP_URL || "http://localhost";
const writeExtensionAppUrl = async (appUrl = "http://localhost") => {
const filePath = path.join(__dirname, TARGET_FILE_PATH);

try {
await fs.writeFile(filePath, `export const APP_BASE_URL = '${baseUrl}';\n`);
await fs.writeFile(filePath, `export const APP_BASE_URL = '${appUrl}';\n`);
} catch (err) {
console.log("Error adding baseUrl to extensions:", err);
}
};

writeExtensionAppUrl();
export default writeExtensionAppUrl;
```

### Key Steps:
Expand All @@ -73,7 +71,8 @@ const host = new URL(process.env.SHOPIFY_APP_URL || 'http://localhost')

// Add SHOPIFY_APP_URL to extension
if (process.env.NODE_ENV === 'development') {
require('./utils/extension-app-url');
const writeExtensionAppUrl = require('./utils/extension-app-url');
writeExtensionAppUrl(process.env.SHOPIFY_APP_URL);
}
[...]
```
Expand Down

0 comments on commit 0944ef0

Please sign in to comment.