-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from ba-st/22-CORS-not-working-on-error
Fixed CORS failing after an error
- Loading branch information
Showing
5 changed files
with
55 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
source/Stargate-Model/CrossOriginResourceSharingAfterFilter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Class { | ||
#name : #CrossOriginResourceSharingAfterFilter, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'allowedOrigins' | ||
], | ||
#category : #'Stargate-Model-CORS' | ||
} | ||
|
||
{ #category : #'instance creation' } | ||
CrossOriginResourceSharingAfterFilter class >> allowing: origins [ | ||
|
||
^ self new initializeAllowing: origins | ||
] | ||
|
||
{ #category : #initialization } | ||
CrossOriginResourceSharingAfterFilter >> initializeAllowing: origins [ | ||
|
||
allowedOrigins := origins | ||
] | ||
|
||
{ #category : #'tea action' } | ||
CrossOriginResourceSharingAfterFilter >> teaEvalActionOnRequest: request response: response [ | ||
|
||
| requestOrigin requestOriginUrl | | ||
|
||
requestOrigin := request headers at: 'Origin'. | ||
requestOriginUrl := requestOrigin asUrl. | ||
|
||
allowedOrigins | ||
detect: [ :origin | origin = requestOriginUrl ] | ||
ifFound: [ :allowedOrigin | | ||
response headers | ||
at: 'Access-Control-Allow-Origin' put: requestOrigin; | ||
at: 'Vary' put: 'Origin' ]. | ||
|
||
^ response | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters