fable-compiler / repl

Fable online REPL
http://fable.io/repl
MIT License
64 stars 37 forks source link

Running Repl with WebWorker locally #103

Closed PawelStadnicki closed 4 years ago

PawelStadnicki commented 4 years ago

How did you manage to run Repl locally? When I deploy it is ok, but locally I'm constantly fighting with instantiating worker.min.js. I cannot get rid of 403 error

MangelMaxime commented 4 years ago

Hello, can you please tell me which command you are using to run it locally?

PawelStadnicki commented 4 years ago

Hello, when I run the fable-repl project itself it is just

build WatchApp

However I really needed almost the same functionality as a part of my app so I moved the logic to my fable project which is based on regular SAFE template. I run it through

fake build --target run

In both cases I have following or similar url:

Cannot create F# checker Error: [ASSEMBLY LOAD] 403: Forbidden
    at http://localhost:8090/fable-standalone/worker.min.js

In order to develop it I must deploy it regulary so it is a lot of burden (despite the fact that I'm running my app just on Azure Blob Static Website, where the deployment is just copying the files)

MangelMaxime commented 4 years ago

Is your client application hosted on the same port accessed using http://localhost:8090/ in the browser url?

403 is in general an HTTP error meaning that you don't have the permission to access the ressource. Can you please check that you are not requiring authentication for the requested files? If you do, you have to remove the authentication security or you need to provide the required authentication information required by your server.

I think the REPL is already using the WebWorker locally so I don't think it's a problem with this repository but more with the changes you made for your project or how you integrated it.

PawelStadnicki commented 4 years ago

Port is same. Fable-Repl is working fine locally on my machine so it is definately something wrong with enviroment but cannot find the reason.

As I said, I'm using the plain SAFE template so I have a server part despite I'm not using it. In the webpack are strange settings for devServerProxy and sockets which target 127.0.0.1 nad have some sockets and apis like:

    devServerProxy: {
       // redirect requests that start with /api/* to the server on port 8085
       '/api/*': {
           target: 'http://127.0.0.1:' + (process.env.SERVER_PROXY_PORT || "8095"),
              changeOrigin: true
          },
       // redirect websocket requests that start with /socket/* to the server on the port 8085
       '/socket/*': {
           target: 'http://127.0.0.1:' + (process.env.SERVER_PROXY_PORT || "8095"),
           ws: true
          }
      },

which could make the web workers problematic

But it still all works after deployment

MangelMaxime commented 4 years ago

This webpack config is needed because in SAFE stack you want to redirect the API call the "dotnet server" which serves the API. So basically, it says to webpack if you received a call for a route like /api/something redirect it to the "dotnet server" located at http://127.0.0.1:8085.

When deploying you don't have this config because all the dotnet server is serving both the APIs and the static files.

You should check if you can access http://localhost:8090/fable-standalone/worker.min.js. Just by copying the path in your browser URL http://localhost:8090/fable-standalone/worker.min.js. If you can't then you definitely have something wrong in your webpack and/or server configuration.

There is not much I can do without a simple reproduction code because it's not a problem of this repo.

MangelMaxime commented 4 years ago

I am closing because we can't do much more in current state.