![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
cors-test-proxy
Advanced tools
This is a reverse proxy for integration testing web apps against backend services.
DO NOT USE IN PRODUCTION. This bypasses the CORS security mechanism.
cors-test-proxy
solves this by disabling CORS on the backend. It's a reverse proxy for backend APIs that spoofs the required CORS responses (including preflight requests). You don't need to modify your services to handle special CORS responses for testing.
The cors-test-proxy
module exports a factory function for creating a proxy server. The factory function takes a router function as an argument. The router is provided a request
object and should return a host to proxy the request to.
Suppose you have a single API service running on port 4567. This forwards all requests to localhost:4567
. The proxy listens on port 8001.
var createProxy = require('cors-test-proxy')
createProxy(() => 'http://localhost:4567').listen(8001)
+--------------------+ 8080
| webpack dev server |<---------------+
+--------------------+ |
docker-compose |
.......................................... | +---------+
. +---------+ 4567 . +---| browser |
. | waldorf |<---+ . | +---------+
. +---------+ | . |
. | +---------+ . |
. +---------+ 4567 | cors | . 8001 |
. | yolanda |<---+----| test |<------------+
. +---------+ | | proxy | .
. | +---------+ .
. +---------+ 4567 .
. | janice |<---+ .
. +---------+ .
..........................................
In this example, we are testing against a cluster of microservices. By adding additional routing logic, cors-test-proxy
can direct requests to more than one server. This mimics an API gateway that would be used in production.
cors-test-proxy
can also be built into a Docker container, as shown below.
proxy.js
:
var createProxy = require('cors-test-proxy')
const waldorf = 'http://waldorf:4567'
const yolanda = 'http://yolanda:4567'
const janice = 'http://janice:4567'
const routes = {
'/v1/ruleset': waldorf,
'/v1/project': yolanda,
'/v1/sessions': janice,
'/v1/users': janice,
'/v1/accounts': janice,
}
function router(req) {
const match = Object.keys(routes).filter(k => req.url.startsWith(k))
if (match.length < 1)
throw new Error(`no route for ${req.url}`)
return routes[match[0]]
}
createProxy(router).listen(8001)
package.json
:
{
"name": "ion-cors-proxy",
"version": "0.1.0",
"dependencies": {
"cors-test-proxy": "^0.1.0"
}
}
Dockerfile
:
FROM alpine:3.4
RUN apk add --no-cache nodejs
COPY . /usr/app
WORKDIR /usr/app
RUN npm install
CMD ["node", "proxy.js"]
EXPOSE 8001
FAQs
Reverse proxy for integration testing
The npm package cors-test-proxy receives a total of 0 weekly downloads. As such, cors-test-proxy popularity was classified as not popular.
We found that cors-test-proxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.