Giter Club home page Giter Club logo

Comments (9)

brianleroux avatar brianleroux commented on July 17, 2024 1

on a flight today but have this in my queue!

from functions.

brianleroux avatar brianleroux commented on July 17, 2024

oh! good call. I wonder… you still might want the s3 url behavior in some cases. maybe we add arc.http.helpers._static for the _static URLs ?

from functions.

mikemaccana avatar mikemaccana commented on July 17, 2024

Hrm a static and a _static seems a bit obscure. Maybe something more explicit if both are needed?

from functions.

brianleroux avatar brianleroux commented on July 17, 2024

yeah…its weird! what would u suggest ?

from functions.

mikemaccana avatar mikemaccana commented on July 17, 2024

OK so I've read https://github.com/arc-repos/architect/blob/master/changelog.md and the updated https://arc.codes/guides/static-assets and I'm still not totally clear.

I gather:

  • We can access blobs in S3 buckets directly using _static (new in Arc 5.5)
  • We can access S3 through lambda (which is what Arc 5.0 did)

Is that correct?

In what circumstances would we need the older behavior?

The changelog should also have advice on what to change during the upgrade for static assets to keep working. Maybe we need to move files, maybe we need to call static() differently, I'm not sure.

from functions.

brianleroux avatar brianleroux commented on July 17, 2024

Yo! Ya this is a bit confusing sorry! I'll try to explain.

The root S3 proxy (using arc.proxy.public) and the 'extra' /_static proxy can only handle text content currently (a limitation of API Gateway). So you'll still probably want to load binary content like images, videos, fonts, etc from S3 using the direct S3 URLs.

For text content (json, html, js, css, etc) you will probably want to use either proxy because now your static assets are on the same origin as your dynamic routes and thusly more secured (without CORs). The root proxy passes through Lambda so you get more power BUT that comes at the cost of a Lambda execution so we were motivated to add /_static fallback for devs that want to avoid the Lambda execution but still have the benefits of a same origin.

from functions.

mikemaccana avatar mikemaccana commented on July 17, 2024

Hey @brianleroux I'm a little stuck on this one (trying to update arc-example-ws so it works on current code).

I appreciate the detailed answer, but I'm getting lost here. It seems like a really simple problem. https://arc.codes/guides/static-assets does not help as it is out of date:

  • I am on the sandbox.
  • I have a client side JS file
  • let clientSideJS = static('/index.mjs') returns a broken URL /index.mjs
  • let clientSideJS = '/_static/index.mjs' works fine,

What is the correct way to refer to a JS file in public so that it will work on sandbox, staging, production, etc?

I can update the docs accordingly if you need.

from functions.

mikemaccana avatar mikemaccana commented on July 17, 2024

Still occurs on @architect/architect 5.6.3 + @architect/functions 3.0.1

from functions.

brianleroux avatar brianleroux commented on July 17, 2024

should be fixed in latest!

from functions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.