Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrewbrey/remix-curl
A demo of using Remix to send different responses depending on if the client is a browser or curl
https://github.com/andrewbrey/remix-curl
curl demo remix remix-run vercel
Last synced: 13 days ago
JSON representation
A demo of using Remix to send different responses depending on if the client is a browser or curl
- Host: GitHub
- URL: https://github.com/andrewbrey/remix-curl
- Owner: andrewbrey
- License: mit
- Created: 2022-04-05T20:43:31.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-06T00:26:32.000Z (almost 3 years ago)
- Last Synced: 2024-11-16T20:35:00.414Z (2 months ago)
- Topics: curl, demo, remix, remix-run, vercel
- Language: TypeScript
- Homepage: https://remix-curl.vercel.app/
- Size: 187 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Remix Curl Demo
This is demo of how you can use the fact that Remix provides you with a real server to send one response to web browsers and another response to a `curl` client.
## Demo
This demo is deployed to `Vercel` and can be viewed in a web browser at https://remix-curl.vercel.app/
Alternatively, you can curl this same url with:
```bash
curl --silent https://remix-curl.vercel.app
```to see how this site sends a _completely different_ response to `curl`, and in fact, the response to `curl` takes advantage of the fact that it's being called from a terminal and the plaintext response includes ansi style escape codes so that you get a pretty output in the terminal just like you do in the browser!
### Notes
- As of this writing (April 5th, 2022), Remix doesn't support configuring `esbuild` with custom `external` modules (may be fixed if they merge https://github.com/remix-run/remix/pull/1841). Unfortunately in addition to this, the `external` modules declared _internally_ by Remix are the Node built-ins (`process`, `fs`, etc) but _only_ those without the `node:` specifier prefix, which means any 3rd party dependency that references e.g. `node:process` (or any other Node built-in via its `node:` prefixed specifier) will cause a build error.
Since I wanted to use the [boxen module](https://github.com/sindresorhus/boxen) by @sindresorhus in the `curl` response text, and this module references `node:process`, I needed to use `patch-package` as a quick way to ensure that the un-prefixed Node built-in was being referenced by `boxen`.
If at some point either:
- Remix includes _both_ `node:` prefixed and unprefixed Node built-ins in their list of `external` modules for `esbuild`, OR
- Remix allows users to supply their own `external` module list via configurationthen this use of `patch-package` can go away.
### See Also
https://blog.andrewbrey.com/2022-04-05-building-a-curl-able-developer-resume-site-with-remix