Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
ssr site: simplify url type in sst dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed Jul 5, 2024
1 parent 099263d commit bbe707c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pkg/platform/src/components/aws/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,9 @@ export class Astro extends Component implements Link.Linkable {
* Otherwise, it's the autogenerated CloudFront URL.
*/
public get url() {
return all([this.cdn?.domainUrl, this.cdn?.url]).apply(
if (!this.cdn) return;

return all([this.cdn.domainUrl, this.cdn.url]).apply(
([domainUrl, url]) => domainUrl ?? url,
);
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/platform/src/components/aws/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,9 @@ if(request.headers["cloudfront-viewer-longitude"]) {
* Otherwise, it's the autogenerated CloudFront URL.
*/
public get url() {
return all([this.cdn?.domainUrl, this.cdn?.url]).apply(
if (!this.cdn) return;

return all([this.cdn.domainUrl, this.cdn.url]).apply(
([domainUrl, url]) => domainUrl ?? url,
);
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/platform/src/components/aws/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ export class Nuxt extends Component implements Link.Linkable {
* Otherwise, it's the autogenerated CloudFront URL.
*/
public get url() {
return all([this.cdn?.domainUrl, this.cdn?.url]).apply(
if (!this.cdn) return;

return all([this.cdn.domainUrl, this.cdn.url]).apply(
([domainUrl, url]) => domainUrl ?? url,
);
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/platform/src/components/aws/remix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,9 @@ export class Remix extends Component implements Link.Linkable {
* Otherwise, it's the autogenerated CloudFront URL.
*/
public get url() {
return all([this.cdn?.domainUrl, this.cdn?.url]).apply(
if (!this.cdn) return;

return all([this.cdn.domainUrl, this.cdn.url]).apply(
([domainUrl, url]) => domainUrl ?? url,
);
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/platform/src/components/aws/solid-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,9 @@ export class SolidStart extends Component implements Link.Linkable {
* Otherwise, it's the autogenerated CloudFront URL.
*/
public get url() {
return all([this.cdn?.domainUrl, this.cdn?.url]).apply(
if (!this.cdn) return;

return all([this.cdn.domainUrl, this.cdn.url]).apply(
([domainUrl, url]) => domainUrl ?? url,
);
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/platform/src/components/aws/svelte-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ export class SvelteKit extends Component implements Link.Linkable {
* Otherwise, it's the autogenerated CloudFront URL.
*/
public get url() {
return all([this.cdn?.domainUrl, this.cdn?.url]).apply(
if (!this.cdn) return;

return all([this.cdn.domainUrl, this.cdn.url]).apply(
([domainUrl, url]) => domainUrl ?? url,
);
}
Expand Down

0 comments on commit bbe707c

Please sign in to comment.