Skip to content

Shielding issue with copied Request #1385

@TartanLlama

Description

@TartanLlama
/// <reference types="@fastly/js-compute" />

import { env } from "fastly:env"; 
import { Shield } from "fastly:shielding";

async function app(event) {
    console.log("FASTLY_SERVICE_VERSION:", env('FASTLY_SERVICE_VERSION') || 'local');
    const req = event.request;
    const newReq = new Request(req.url, {
      body: req.body,
      method: req.method,
    });
    const shield = new Shield('iad-va-us');
    if (shield.runningOn()) {
        return await fetch('https://http-me.fastly.com/anything', { backend: 'httpme' });
    }
    return await fetch(newReq, { backend: shield.encryptedBackend() });
}

addEventListener("fetch", (event) => event.respondWith(app(event)))

This code results in the following error:

Error while running request handler: Requested backend named '**fastly-shield-INTER-IAD-SSL**NRT' does not exist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions