Skip to content

Commit

Permalink
remove CORS headers (#118)
Browse files Browse the repository at this point in the history
Co-authored-by: Bhaven Dedhia <[email protected]>
  • Loading branch information
diljale and Bhaven Dedhia authored Sep 3, 2024
1 parent c21c515 commit b47ca6f
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 46 deletions.
11 changes: 0 additions & 11 deletions samples/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ For rapid testing, you can initiate a liveness session by adding the <azure-ai-v
<azure-ai-vision-faceanalyzer token="***FACE_API_SESSION_TOKEN***"></azure-ai-vision-faceanalyzer>
```

#### Hosting environment updates

This SDK uses WebAssembly, SharedArrayBuffer, and MediaDevices.getUserMedia() features from Web API. To host your web app, your hosting environment must support secure context. In particular, the response headers must include the following as baseline requirement:

- `Content-Type` must be set properly according to the MIME type.
- For top-level documents:
- `Cross-Origin-Opener-Policy` must be set to `same-origin` .
- `Cross-Origin-Embedder-Policy` must be set to `require-corp` (more widely supported) or `credentialless` (less widely supported).
- For nested documents and subresources:
- `Cross-Origin-Resource-Policy` must not be empty and must be set appropriately.

#### Deployment

It's important to note that essential assets like WebAssembly (wasm) files and worker JavaScript files are packaged within the NPM distribution. During deployment to a production environment, it's essential to include these assets. As an example, you can deploy the 'faceanalyzer-assets' from the node_modules\azure-ai-vision-faceanalyzer folder to the root assets directory after the npm installation to ensure proper asset deployment.
Expand Down
1 change: 1 addition & 0 deletions samples/web/angularjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ yarn-error.log
/libpeerconnection.log
testem.log
/typings
public/faceanalyzer-assets

# System files
.DS_Store
Expand Down
9 changes: 1 addition & 8 deletions samples/web/angularjs/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,7 @@
"buildTarget": "face-angular-js:build:development"
}
},
"defaultConfiguration": "development",
"options": {
"headers": {
"X-Frame-Options": "SAMEORIGIN",
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp"
}
}
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n"
Expand Down
7 changes: 0 additions & 7 deletions samples/web/angularjs/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ app.use(express.json());
const storage = multer.memoryStorage();
const upload = multer({ storage: storage });

// **IMPORTANT**: This middleware sets headers for all responses, static or not.
app.all("*", function (req, res, next) {
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
next();
});

app.get("/", (_req, res) => {
res.sendFile(`${__dirname}/dist/face-angular-js/browser/index.html`);
});
Expand Down
1 change: 1 addition & 0 deletions samples/web/nextjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# production
/build
public/faceanalyzer-assets

# misc
.DS_Store
Expand Down
3 changes: 0 additions & 3 deletions samples/web/nextjs/components/FaceAnalyzerSampleClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import Image from "next/image";
import { ChangeEvent, useState } from "react";
import dynamic from "next/dynamic";

// Only import type because "azure-ai-vision-faceanalyzer" is already initialized in face_analyzer/face.tsx
import type { FaceAnalyzedResult } from "azure-ai-vision-faceanalyzer";

// Result View static assets
const checkmarkCircleIcon = "CheckmarkCircle.png";
const heartPulseIcon = "HeartPulse.png";
Expand Down
9 changes: 0 additions & 9 deletions samples/web/nextjs/middleware.js

This file was deleted.

2 changes: 1 addition & 1 deletion samples/web/vuejs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
node_modules
/dist

public/faceanalyzer-assets

# local env files
.env.local
Expand Down
7 changes: 0 additions & 7 deletions samples/web/vuejs/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ app.use(express.json());
const storage = multer.memoryStorage();
const upload = multer({ storage: storage });

// **IMPORTANT**: This middleware sets headers for all responses, static or not.
app.all("*", function (req, res, next) {
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
next();
});

app.get("/", (_req, res) => {
res.sendFile(`${__dirname}/dist/index.html`);
});
Expand Down

0 comments on commit b47ca6f

Please sign in to comment.