npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@b-dev/next-proxima

v1.0.0

Published

Next.js image proxy. Makes it possible to bypass authenticated image and dynamic domains in next/image component

Downloads

17

Readme

❔ Motivation

This library enables the usage of next/image with dynamic domains. When working with external providers such as Facebook, Instagram, Etsy, Medium, and others, images often originate from dynamic subdomains. For example, you might retrieve the first image from scontent-akl1-1.cdninstagram.com and the second image from scontent-akl3-1.cdninstagram.com. While temporarily adding these subdomains to the Next.js configuration might work, it lacks reliability as the subdomains can change unpredictably. Unfortunately, Next.js doesn't currently support regex patterns in the configuration file to handle dynamic domains.

This library provides an additional feature where it can also be used to bypass authenticated images from the server or backend by passing a token. This allows you to fetch and display images that require authorization or authentication in your Next.js application.

To keep up with the ongoing discussion regarding Next.js support for this feature, you can refer to this Discussion and this Pull Request.

Please consider the following aspects:

  • Insufficiently strict regex patterns can create security vulnerabilities, so it's important to ensure your patterns are sufficiently strict.
  • As this library acts as a proxy, there may be a marginal increase in bandwidth costs. However, this increase should be minimal unless you're dealing with a high-volume project with millions of requests per month.

⚠️ Limitations:

Please be aware of the following limitations when using this library:

  • Compatibility with Netlify may vary. Test thoroughly before deploying to a Netlify environment.
  • Compatibility with serverless-next.js may be limited. Evaluate the compatibility with your specific serverless setup.

Feel free to modify the content further to align with your preferences and project requirements.

🧰 Installation

$ npm i --save @b-dev/next-proxima

# or

$ yarn add @b-dev/next-proxima

💻 Use

It is really simple to setup, you just need to add a new API route that exports one function. The name of the endpoint is up to you.

// pages/api/imageProxy.ts

import { withImageProxy } from '@b-dev/next-proxima'

export default withImageProxy({ whitelistedPatterns: [/^https?:\/\/(.*).github.com/] })

and now you prefix the image you want to use:

import NextImage from 'next/image'

export function SomeComponent() {
  const actualImageUrl = 'https://cdn-images-1.github.com/max/1024/1*xYoAR2XRmoCmC9SONuTb-Q.png'

  return <NextImage src={`/api/imageProxy?imageUrl=${actualImageUrl}`} width={700} height={300} />
}

Support

If you have any questions or need assistance with the project, feel free to reach out to me directly at [email protected]. I'm more than happy to help and address any concerns you may have.

🤲🏻 Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  • If you have suggestions for adding or removing projects, feel free to open an issue to discuss it, or directly create a pull request after you edit the README.md file with necessary changes.
  • Create individual PR for each suggestion.

Creating A Pull Request

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request