Skip to content

Commit

Permalink
Merge branch 'main' into DOP-5203
Browse files Browse the repository at this point in the history
  • Loading branch information
seungpark authored Nov 22, 2024
2 parents c0926d5 + 8cf4a65 commit c1d07a0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
46 changes: 46 additions & 0 deletions netlify/functions/fetch-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import axios from 'axios';

async function handleURL({ url }) {
try {
const { data } = await axios.get(url, {
// Throws error whenever response status >= 400
validateStatus: (status) => {
console.log(`Returning status ${status} for ${url}`);
return status < 400;
},
});

return new Response(data, {
status: 200,
headers: {
'Cache-Control': 'public, durable, max-age=300',
},
});
} catch (err) {
console.log({ err });

if (axios.isAxiosError(err) && err.response) {
return new Response(null, { status: err.response.status });
}
return new Response(null, { status: 500 });
}
}

// This function exists only to help proxy URLs that were originally causing 403 errors, potentially due
// to IP addresses. (DOP-5189)
async function handler(req, context) {
const params = context.url.searchParams;
const url = params.get('url');

// Log to help keep track of requests
console.log({ req, context });

if (url) {
return handleURL({ url });
}

// Expected to only work when a url query param is defined
return new Response(null, { status: 400 });
}

export default handler;
4 changes: 3 additions & 1 deletion src/components/ActionBar/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export const searchInputStyling = ({ mobileSearchActive }) => css`
${displayNone.onMedium};
@media ${theme.screenSize.upToMedium} {
font-size: ${theme.fontSize.default};
input[type='search'] {
font-size: ${theme.fontSize.default};
}
}
${mobileSearchActive &&
Expand Down

0 comments on commit c1d07a0

Please sign in to comment.