Skip to content

Commit

Permalink
fix: Solve multiple issues from sveltekit breaking changes (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
HalfdanJ authored Sep 13, 2022
2 parents c91f175 + b462a29 commit 450f29d
Show file tree
Hide file tree
Showing 5 changed files with 750 additions and 175 deletions.
9 changes: 6 additions & 3 deletions files/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ const ssr = async (request_, response) => {
let request;

try {
request = await getRequest(getBase(request_.headers), request_);
request = await getRequest(
{base: getBase(request_.headers), request: request_});
} catch (error) {
response.statusCode = error.status || 400;
return response.end(error.reason || 'Invalid request body');
response.end(error.reason || 'Invalid request body');
return;
}

setResponse(response, await server.respond(request, {
Expand All @@ -42,8 +44,9 @@ const ssr = async (request_, response) => {
* @returns
*/
function getBase(headers) {
const protocol = 'https';
const host = headers.host;
const isLocalhost = host.split(':')[0] === 'localhost';
const protocol = headers['x-forwarded-proto'] || (isLocalhost ? 'http' : 'https');
return `${protocol}://${host}`;
}

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function entrypoint(options = {}) {
const {out = 'build', external = []} = options;

return {
name: 'appengine',
name: 'svelte-adapter-appengine',

async adapt(builder) {
const temporary = builder.getBuildDirectory('svelte-adapter-appengine');
Expand Down
Loading

0 comments on commit 450f29d

Please sign in to comment.