Skip to content

Commit

Permalink
Merge pull request #233 from storybookjs/fix/target-url
Browse files Browse the repository at this point in the history
Fix target url in error feedback
  • Loading branch information
yannbf authored Dec 20, 2022
2 parents e04b3a1 + 586f746 commit 16bcf70
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/setup-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const sanitizeURL = (url: string) => {
};

export const setupPage = async (page: Page) => {
const targetURL = new URL('iframe.html', process.env.TARGET_URL).toString();
const targetURL = process.env.TARGET_URL;

const viewMode = process.env.VIEW_MODE || 'story';
const renderedEvent = viewMode === 'docs' ? 'docsRendered' : 'storyRendered';
const { packageJson } = await readPackageUp();
Expand All @@ -40,7 +41,8 @@ export const setupPage = async (page: Page) => {
);
}

await page.goto(targetURL, { waitUntil: 'load' }).catch((err) => {
const iframeURL = new URL('iframe.html', process.env.TARGET_URL).toString();
await page.goto(iframeURL, { waitUntil: 'load' }).catch((err) => {
if (err.message?.includes('ERR_CONNECTION_REFUSED')) {
const errorMessage = `Could not access the Storybook instance at ${targetURL}. Are you sure it's running?\n\n${err.message}`;
throw new Error(errorMessage);
Expand Down

0 comments on commit 16bcf70

Please sign in to comment.