I am trying to copy Watson conversation simple node js application from GitHub (https://github.com/watson-developer-cloud/conversation-simple) and running in my local.
I have created service key and setup workspace. Next I have updated Workspace ID, User ID & Password in .env, app.js file. I have imported existing car_workspace.json file only and used corresponding Workspace ID.
While running in local host I am getting "The app has not been configured with a environment variable."
Please help me to understand if I am missing anything.
Try to use the .env file and make sure the are no spaces between = and the end of the line.
You need to have one file called .env, within the project from IBM Developers has one example, just delete the word: example, and the file will called just with .env in your Directory, like this image:
And replace the values with your Service Credentials and your Workspace_id
# Environment variables
WORKSPACE_ID=490a9b3b-xxxxxxxxxxxxx
CONVERSATION_USERNAME=xxxxxxxxxxxxxx-e1ebbc10
CONVERSATION_PASSWORD=Bxxxx6FdzXxL
Check another format:
USERNAME="yourUsername"
And in your app.js:
var workspace = process.env.WORKSPACE_ID || '<workspace-id>';
console.log(process.env.WORKSPACE_ID);//your value will appear
If you want, has another form, you can set the workspace_id and username, password in your app.js file.
var username = 'usernameServiceCredentials'
var password = 'passwordServiceCredentials'
var workspace_id = 'workspaceFromConversation'
See the dotenv documentation for more information.
You can see your Credentials inside your Workspace -> Deploy -> Credentials
Related
I'm trying to setup Apple Pay via Stripe, which requests access to a file to verify domain ownership. The problem I'm having is that this file has no extension, so either React, Azure or my .NET application does not like it!
I've tried various solutions to date within the web.config but to no avail.
The file in question is: /.well-known/apple-developer-merchantid-domain-association
My project is a .NET project running a React SPA. I've added the file mentioned above to the /public folder, too.
I can access .txt files in the same folder, so the path/folder is accessible - It seems to be a problem with the lack of extension.
I've managed to resolve this with the following, and ensuring the ./well-known and subfiles are in my project root.
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, #".well-known")),
RequestPath = new PathString("/.well-known"),
DefaultContentType = "application/json",
ServeUnknownFileTypes = true
});
I created a new outlook add-in using the react-taskpane option in the yeoman generator.
I need to insert a new html page to prompt it when there's no signed user is present.
This is the file structure:
I didn't change the manifest file. But, I included the following in the webpackconfig.js file:
new HtmlWebpackPlugin({
filename: "Handler.html",
template: "./src/AppCommon/Auth/Handler.html",
chunks: ["Handler"],
}),
When I run npm run build Handler.html gets included in the dist folder.
How can I prompt that page in a separate window? (The logic to check whether the user is logged in or not is not needed).
I used this line for that:
window.location.href = app.hostUrl + "/src/AppCommon/Auth/Handler.html";
And I'm getting this error:
Cannot GET /src/AppCommon/Auth/Handler.html
How can I define the path correctly?? Thank you in advance
First of all, if you want a separate window, don't use window.location.href. Use the Office.UI.displayDialogAsync method. For more details, see the official documentation: Use the Office dialog API in Office Add-ins
Secondly, I don't think you should have the /src in the URL, especially if you are in production mode and serving the file from /dist.
So ipfs gives us https based urls for files yet they are all unique, per-file and hash based. I want to get something like that yet for expandable folders with updatable files (say have ‘parent hash/{fileIdPath}’ link). How to get a link to a file from the ipfs Mutable File System (MFS) (a link that would stay the same after I update the file)?
If I am understand the question you want to get access to the URL from a hash file path, please post your code so we can see what you have tried so far and what specifically is the issue
Here is a ref to IPFS
You will need a clients to access those resources over http
For e.g. ipfs-http-client, js-ipfs for js access
using ipfs-http-client
please install it like so
//npm install ipfs-http-client#42.0.1 if you want a specific version
npm install --save ipfs-http-client
Setup your permissions
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://example.com"]'
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST", "GET"]'
Now you can access the information with client
const ipfs = window.IpfsHttpClient()
sample js
With the JS client, install js-ipfs
import { create } from 'ipfs-http-client'
const client = create()
// add your addres below and get the contents
// dor e.g. const client = create(new URL('http://istart.work:1010'))
const client = create(new URL('http://127.0.0.1:1010'))
const { cid } = await client.add('Hello world!')
I'm fetching data from commercejs.com and my localhost shows some error as "Invalid public key given to Commerce.js client". I choose the public api key one tho
This is my commerce.js:
import Commerce from '#chec/commerce.js';
export const commerce = new Commerce(process.env.REACT_APP_CHEC_PUBLIC_KEY, true);
This is my env:
REACT_APP_CHEC_PUBLIC_KEY=pk_test_32015299720e5050ac997c8e08a77c1a0e24bf21215b7
Put .env file in your project root
https://commercejs.com/docs/community/faq/
I'm following the same tutorial.
Try two things:
Restart your local server. Stop with CTRL+C, then run npm start.
Try using your Public Key (not test key).
Anyone else with issues, double check you've spelled everything correctly in commerce.js. I had written REACT_APP_CHECK instead of CHEC.
Your API key is not being provided to Commerce.js when you construct Commerce.
import { Commerce } from '#chec/commerce.js';
const commerce = new Commerce('put_your_api_key_here');
When using an environment variable, be sure that it is being loaded correctly. In this case please ensure that the .env file in your project is in the project root folder (same level as package.json), and that it has the environment variable defined correctly as referenced by your code. e.g.
const commerce = new Commerce(process.env.REACT_APP_CHEC_PUBLIC_KEY);
project
- node_modules
- src
-.env
-.gitignore
- README.md
- package.json
I want to use an API key for one of my frontend components, but I can't seem to get require('dotenv').config() to work. It works perfectly fine in my backend. Do I need a relative path for it to work?
My file structure is
client
-src
--components
---component.js
server
-server.js
.env
(so require('dotenv').config() works in server.js, but not component.js)
I have a public key for my frontend and a secret key for my backend both in .env. When I try console.log(process.env.REACT_APP_FKEY) to check my public key, I get undefined.
Any help is appreciated!
React cannot access files out side the react project which I assume is client. You can create an env.local file in your client folder, and inside there you want to start your variable names with REACT_APP first, example.
So new file structure
client
-src
--components
---component.js
-.env.local // inside client folder
server
-server.js
-.env //this should be inside server folder
the .env.local file
REACT_APP_FKEY=your_key
and then you can access it as, process.env.REACT_APP_FKEY
This way you do not need dotenv on your FE