0

I'm using a +server.ts file to mask the path to a Netlify function. While the redirect and the function both work, I still get to see a console error, e.g. when clicking on a link to /download?get=filename.

Error: Not found: /download/

Here's the code for the server component.

// routes/download/+server.ts

import type { RequestHandler } from '@sveltejs/kit';

export const GET: RequestHandler = async () => {
    const options: ResponseInit = {
        status: 302,
        headers: {
            location: '/.netlify/functions/download'
        }
    };

    return new Response(null, options);
};

I'd love to get rid of the client error, but I'm not sure what causes this.

2
  • Can you try this route => routes/api/download/+server.ts Commented Apr 2, 2023 at 17:25
  • I tried to replicate it but I couldn't get a 404 nor such log message. Please, try by creating a minimal reproducible code. Is this error shown in a special place or after some code (like a fetch or something)? Commented Apr 3, 2023 at 14:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.