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

Add example of (and fix) static asset proxy #254

Merged
merged 4 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion templates/demo-store/oxygen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ declare const process: {env: {NODE_ENV: string}};
const requestHandler = createRequestHandler({
build: remixBuild,
mode: process.env.NODE_ENV,
shouldProxyAsset: () => false,
/**
* By default, Hydrogen will prefix all static assets with a CDN url.
* If you need to serve static assets from the same domain or from the root,
* update the `shouldProxyAsset: (url: string) => boolean` function below
* to return `true` when the url (pathname) matches your asset.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the comment. Would be nice if we augmented the TS definition for the property so that this shows up when you're using shouldProxyAsset as well, so that it becomes a little piece of documentation for it.

Stretch goal, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey why the heck not, right?

// shouldProxyAsset: () => false,
// TODO: Remove example
shouldProxyAsset(url) {
return url.includes('party-town-babay.json');
},
});

export default {
Expand Down
7 changes: 7 additions & 0 deletions templates/demo-store/public/party-town-babay.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"time": {
"to": {
"party": true
}
}
}